Getting a connection
The first thing we will do is establish a connection with our signaling server. The signaling server that we built in Chapter 4, Creating a Signaling Server, is entirely based on the WebSocket protocol. The great thing about the technology that we built on top of is that it requires no extra libraries to connect to the server. It simply uses the built-in power of WebSocket in most up-to-date browsers today. We can just create a WebSocket object directly, and connect to our server in no time at all.
Tip
The other wonderful thing about using WebSockets is that the standard is much further along in the process. On most browsers today, there are no checks or prefixes needed and it should be readily available. As always, however, check the latest documentation for your browser.
We can start by creating the client.js file that our HTML page includes. You can add the following connection code:
var name, connectedUser; var connection = new WebSocket('ws://localhost:8888');...