Building a chatting application with WebSockets
We now know how many browsers are connected. Suppose we want to build a chat room where users can type a message in their respective browsers and send the message to all the connected users instantly.
Sending a message to the server
We will let the user input a message and then send the message to the node.js
server. The server will then forward the message to all the connected browsers. Once a browser receives the message, it displays it in the chat area. In this case, the users are connected to the instant chat room once they load the web page.