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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.