Reading 19 Socket.io Namespaces and Rooms - liz-kavalski-401-advanced-javascript/seattle-javascript-401n13 GitHub Wiki
Rooms and Namespaces
- Can assign endpoints or paths
- Help minimized TCP connections and separate concerns within your application
- Dose has a defult
- to customize can use the
of
function on the server-side.
const nsp = io.of('/my-namespace');
nsp.on('connection', function(socket){
console.log('someone connected');
});
nsp.emit('hi', 'everyone!');
- on the client-side it would look like this:
const socket = io('/my-namespace');
- Can also create 'rooms' where people can join or leave
- the room has a unique id
Remote Connections
- There are ways to emit or broadcast messages.
- Don't really get how it works?