List of namespaces in socket.io

2019-07-20 01:15发布

Is there any way to get a list of all the namespaces registered on the socket?

For example, suppose some client connects to a namespace: `socket = io('/some-nsp');

They are now in a namespace automagically because the socket.io does not prevent creating random namespaces.

If I want to go through the list of all existing namespaces and disconnect those users, how could I get such a list.

I've tried io.nsps, but this just is a circular list of junk.

Is there an "official" way to get a list of all the namespaces registered on the socket? I don't want a list of clients. I just want a list of namespaces.

标签: socket.io
1条回答
聊天终结者
2楼-- · 2019-07-20 02:03

You may try this:

Object.keys(io.nsps);
查看更多
登录 后发表回答