how to create/join a namespace in a room on socket.io? -
i use namespaces
in room
's socket.io
features.
i know usefull reminder rooms can see:
- a way emit sockets on namespace's room
io.of('namespace').in('room').emit('event_name', data)
- a way list of sockets in namespace's room
io.of('namespace').clients('room')
but page desn't provide way create/join
socket
specific namespace
in specific room
.
how that? have try following example without success:
socket.join('city').in('district'); io.of('district').clients('/city'); // [] io.of('/district').clients('/city'); // []
you can't join/leave namespaces. namespace part of url when first connect
for example, connecting "http://localhost/district"
connect "district"
namespace.
on server, can join rooms in namespace this:
io.of('/district').on('connection', function(socket){ socket.join('city'); });
Comments
Post a Comment