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

Setting up a default room

In Socket.IO, every socket that makes a connection is assigned a default room to emit messages. This default room could be used for a wide variety of purposes.

A practical use of the default room is to store friends or followers of the socket. When another socket joins the default room of a socket, we can assume that the socket is interested in receiving updates from the room that it has joined.

Other sockets are able to join the default room of any other socket. It isn't safe to assume that the default room of a socket only has one member unless the server-side architecture is set up in this way.

In this recipe, we will let our socket emit messages to the default room of any other connected socket. We will build a drop-down ...

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