Skip to content

Commit

Permalink
refactor: add note about fetchSockets() for parent namespaces
Browse files Browse the repository at this point in the history
Related: #4235
  • Loading branch information
darrachequesne committed Jan 5, 2022
1 parent fc82e44 commit 3bf5d92
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/parent-namespace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Namespace } from "./namespace";
import type { Server } from "./index";
import type { Server, RemoteSocket } from "./index";
import type {
EventParams,
EventNames,
Expand Down Expand Up @@ -64,4 +64,13 @@ export class ParentNamespace<
this.server._nsps.set(name, namespace);
return namespace;
}

fetchSockets(): Promise<RemoteSocket<EmitEvents>[]> {
// note: we could make the fetchSockets() method work for dynamic namespaces created with a regex (by sending the
// regex to the other Socket.IO servers, and returning the sockets of each matching namespace for example), but
// the behavior for namespaces created with a function is less clear
// note²: we cannot loop over each children namespace, because with multiple Socket.IO servers, a given namespace
// may exist on one node but not exist on another (since it is created upon client connection)
throw new Error("fetchSockets() is not supported on parent namespaces");
}
}

0 comments on commit 3bf5d92

Please sign in to comment.