Book Image

Learning Node.js for Mobile Application Development

Book Image

Learning Node.js for Mobile Application Development

Overview of this book

Table of Contents (21 chapters)
Learning Node.js for Mobile Application Development
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
14
Creating an E-Commerce Application Using the Ionic Framework
Index

Using WebSockets in Node.js


Node.js does not come with a default module for using WebSockets. While we have tried so far to avoid third-party solutions and just show you how to work with Vanilla node, this topic is complex enough to put writing a WebSocket handler from scratch well beyond the scope of the book. Therefore, for the remainder of this chapter, we will use the excellent socket.io library. We of course do not imply that this is what you should be using in your own work, and in the Chapter 6, Introducing Ionic, the Going further section at the end of the chapter, we will direct you to alternative solutions and reading materials for WebSockets.

Setting up our project

We will set up a separate project for this chapter, demonstrating how we can create a simple chat application that demonstrates the essentials of using WebSocket.

Create a separate project folder and name it chat-app. In this folder, create a blank file named app.js. Finally, open your terminal or the command prompt,...