reading-notes

Message Queues

Socket.io Chat Example

1. Explain to a non-technical recruiter what the Chat Example (above) does.

This chat example has users who want to chat connect to a server that accepts user-inputted text messages and then disseminates that message to all other users connected to the same server.

2. What proof of life are we getting on the backend from the above app?

On the backend, we’re getting listening on *:3000

3. Socket.IO gives us the i0.emit() method to send an event to everyone. What flag would you use if you want to send a message to everyone except for a certain emitting socket?

io.broadcast.emit()

Rooms

1. What is a room and how might a room be useful?

A room is a channel that clients can join() and leave(). They’re useful if you want clients to only emit and receive events in their own room.

2. How do you join a room?

socket.join('a room')

3. How do you leave a room?

socket.leave('a room)

Namespaces

1. What is a Namespace and what does it allow you to do?

A namespace is a way to separate socket logic, depending on intended functionality. Instead of having connections route to “/”, we can have them be routed to “/banana” or “/pokemon”.

2. Each namespace potentially has its own what? (hint: 3 things)

  1. Event handlers
  2. Rooms
  3. Middlewares

3. Discuss a possible use case for separate namespaces

A use case if we wanted to create a space where only some users have access to, like juicy secrets, for example.

Bookmark and Review

Things I Want To Know More About

Previous Reading

Next Reading