Class Thirteen Notes (401)
Message Queues
Socket.io Chat Example
- The code basically sends a message to the server when a connected user clickes the “submit button”
- On the backend, we can console log the connection and message being sent to the server by the user
- You can use “broadcasting” so the message will be sent to everyone except for the emitting socket;
Rooms
- A room is where only connected users can broadcast and communicate to each other. You can join a room by using
socket.join(room-name)
and leave the room by using socket.on('disconnecting', ()=>{ console.log(''eaving')})
Namespaces
- A namespace is a channel that allows the app to run over a single shared connection
- Each namespace can have its own event-handlers, rooms, and middlewares
- One example usecase of namespaces can be chat channels to different groups of people in an organization, so administrative employees’ messages don’t get passed on to gardeners.
Back to main page
References