O'Reilly logo

Socket.IO Cookbook by Tyson Cadenhead

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Building a Room with a View

In this chapter, we will cover the following recipes:

  • Creating chat channels with namespaces
  • Joining rooms
  • Leaving rooms
  • Listing the rooms that the socket is in
  • Creating private rooms
  • Setting up a default room

Introduction

Socket.IO uses namespaces to keep separate types of messages from colliding with each other. With namespaces, we can be sure that our applications are listening for the correct events.

We can also define arbitrary rooms that our sockets can join or leave. These rooms restrict someone from receiving messages and send them only to interested parties.

In this chapter, you will also learn how to harness namespaces and rooms to create richer real-time experiences.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required