Chapter 3. Having Two-Way Conversations

In this chapter, we will cover the following recipes:

  • Creating a simple chat room
  • Managing the socket life cycle
  • Emitting a private message to another socket
  • Sending messages to all the sockets, except for the sender
  • Building a multiplayer tic-tac-toe game

Introduction

Although we can perform some interesting things with one-way communication, the real power of Socket.IO begins to show when the client and server are both participants in a constant dialog.

In this chapter, we will work through various examples of two-way Socket.IO communication. We will implement various tactics to make bidirectional communication work for our specific needs.

Get Socket.IO Cookbook 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.