From 3bf5d92735e8b57c00a57836211027ebb8eb3eae Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Wed, 5 Jan 2022 08:43:44 +0100 Subject: [PATCH] refactor: add note about fetchSockets() for parent namespaces Related: https://github.com/socketio/socket.io/issues/4235 --- lib/parent-namespace.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/parent-namespace.ts b/lib/parent-namespace.ts index 9ab3a562..a25ab1f4 100644 --- a/lib/parent-namespace.ts +++ b/lib/parent-namespace.ts @@ -1,5 +1,5 @@ import { Namespace } from "./namespace"; -import type { Server } from "./index"; +import type { Server, RemoteSocket } from "./index"; import type { EventParams, EventNames, @@ -64,4 +64,13 @@ export class ParentNamespace< this.server._nsps.set(name, namespace); return namespace; } + + fetchSockets(): Promise[]> { + // 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"); + } }