Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Hour 12. Introducing Socket.IO > Broadcasting Data to Clients

Broadcasting Data to Clients

The real-time counter shows how data on the number of clients can be pushed out to clients in real-time. But, what if you want to enable communicating between clients? You might have a scenario where you want to add chat functionality or perhaps a game where you need to send messages across clients.

To allow clients to communicate with each other, you need to first send a message from a client to the server and then push that message out to clients from the server. The process is as follows:

1. Clients connect to Socket.IO Node.js server.

2. A single client sends a message to the server.

3. The server receives the message.

4. The server broadcasts the message to all other clients.

You have already seen in the last example that you can broadcast messages to clients from a Socket.IO server:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial