When a socket connects to a socket.io server, a connection
event is triggered. The function that handles such event can be overrided to add custom behavior to the connection.
I want to add a function to handle the connection
event, but for a socket.io room.
I was trying something like (with socket.io 0.9.14):
io.sockets.in('someNamespace/someRoom').on('connection', function () {
//custom actions here
}
But it doesn't seem to work. The behavior is attached to the default connection event and triggered on every connection.
Is it possible to achieve what I'm trying? any suggestions?
Thanks in advance.
If I've understood your question clearly, you're trying to use namespaces. Then you should do it like this: