Implementing web sockets in our application
If all this talk of the web socket protocol and its functioning sounded complex, that's because it is. We could make this entire implementation ourselves and spend a few days or even weeks on it, but as with previous chapters, the boring stuff is already taken care of by an external library called socket.iohttps://socket.io/.
Socket.io provides both client-side and server-side libraries and abstracts away most of the complicated stuff, such as establishing a connection and pushing information, and abstracts it behind a convenient API for developers to use.
The socket.io library
The socket.io library provides a convenient abstraction to the process of establishing a socket connection as well as sending and receiving messages.

It works on the basis of event emitters and event listeners. Both the client as well as the server can emit or listen to events. Event listeners or emitters can be declared on a socket instance. This socket instance is created...