Skip to content

Commit 3bf5d92

Browse files
committedJan 5, 2022
refactor: add note about fetchSockets() for parent namespaces
Related: #4235
1 parent fc82e44 commit 3bf5d92

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎lib/parent-namespace.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Namespace } from "./namespace";
2-
import type { Server } from "./index";
2+
import type { Server, RemoteSocket } from "./index";
33
import type {
44
EventParams,
55
EventNames,
@@ -64,4 +64,13 @@ export class ParentNamespace<
6464
this.server._nsps.set(name, namespace);
6565
return namespace;
6666
}
67+
68+
fetchSockets(): Promise<RemoteSocket<EmitEvents>[]> {
69+
// note: we could make the fetchSockets() method work for dynamic namespaces created with a regex (by sending the
70+
// regex to the other Socket.IO servers, and returning the sockets of each matching namespace for example), but
71+
// the behavior for namespaces created with a function is less clear
72+
// note²: we cannot loop over each children namespace, because with multiple Socket.IO servers, a given namespace
73+
// may exist on one node but not exist on another (since it is created upon client connection)
74+
throw new Error("fetchSockets() is not supported on parent namespaces");
75+
}
6776
}

0 commit comments

Comments
 (0)
Please sign in to comment.