ha
Search…
关于本socket.io中文文档
socket.IO website
1 指南(Guide)
2 文档(Docs)
3 客户端-API(Client-API)
4 服务端-API(Server-API)
4.1 server
4.2 命名空间(namespace)
4.2.1 命名空间 namespace
4.2.2 命名空间名称 namespace_name
4.2.3 命名空间连接 namespace_connected
4.2.4 命名空间适配器 namespace_adapter
4.2.5 命名空间到房间 namespace_to_room
4.2.6 命名空间在房间 namespace_in_room
4.2.7 命名空间发送事件参数 namespace_emit_eventname_args
4.2.8 命名空间客户端回调 namespace_clients_callback
4.2.9 命名空间中间件函数 namespace_use_fn
4.2.10 连接事件 event_connect
4.2.11 事件连接 event_connection
4.2.12 可见性标志位 flag_volatile
4.2.13 二进制标志位 flag_binary
4.2.14 本地标记位 flag_local
4.3 socket
4.4 client
Powered By
GitBook
4.2.8 命名空间客户端回调 namespace_clients_callback
callback
(Function)
取连接到此命名空间的客户端ID列表(如果适用,跨所有节点)。
1
const
io
=
require
(
'socket.io'
)();
2
io
.
of
(
'/chat'
),
clients
((
error
,
clients
)
=>
{
3
if
(
error
)
throw
error
;
4
console
.
log
(
clients
)
// => [PZDoMHjiu8PYfRiKAAAF, Anw2LatarvGVVXEIAAAD]
5
})
Copied!
获取命名空间房间中所有客户端的示例:
1
io
.
of
(
'/chat'
).
in
(
'general'
).
clients
((
error
,
clients
)
=>
{
2
if
(
error
)
throw
error
;
3
console
.
log
(
clients
)
// [Anw2LatarvGVVXEIAAAD]
4
})
Copied!
与广播一样,默认值是来自默认命名空间
/
的所有客户端:
1
io
.
clients
((
error
,
clients
)
=>
{
2
if
(
error
)
throw
error
;
3
console
.
log
(
clients
);
// [6em3d4TJP8Et9EMNAAAA, G5p55dHhGgUnLUctAAAB]
4
})
Copied!
Previous
4.2.7 命名空间发送事件参数 namespace_emit_eventname_args
Next
4.2.9 命名空间中间件函数 namespace_use_fn
Last modified
2yr ago
Copy link