Creating the ws-client Module

The ws-client.js module will handle communicating with your Node WebSocket server.

It will have four responsibilities:

  • connecting to the server

  • performing initial setup when the connection is first opened

  • forwarding incoming messages to their handlers

  • sending outgoing messages

Check out how those responsibilities relate to your other components (Figure 17.14).

Figure 17.14  ws-client’s interfaces

ws-client’s interfaces

As you build out your client, you will get a tour of some new ES6 features as well.

Connection handling

First, build out your collection handling. Begin by opening ws-client.js ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.