parent-namespace.d.ts 1.4 KB

123456789101112131415161718192021222324252627282930
  1. import { Namespace } from "./namespace";
  2. import type { Server, RemoteSocket } from "./index";
  3. import type { EventParams, EventsMap, DefaultEventsMap, EventNamesWithoutAck } from "./typed-events";
  4. /**
  5. * A parent namespace is a special {@link Namespace} that holds a list of child namespaces which were created either
  6. * with a regular expression or with a function.
  7. *
  8. * @example
  9. * const parentNamespace = io.of(/\/dynamic-\d+/);
  10. *
  11. * parentNamespace.on("connection", (socket) => {
  12. * const childNamespace = socket.nsp;
  13. * }
  14. *
  15. * // will reach all the clients that are in one of the child namespaces, like "/dynamic-101"
  16. * parentNamespace.emit("hello", "world");
  17. *
  18. */
  19. export declare class ParentNamespace<ListenEvents extends EventsMap = DefaultEventsMap, EmitEvents extends EventsMap = ListenEvents, ServerSideEvents extends EventsMap = DefaultEventsMap, SocketData = any> extends Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData> {
  20. private static count;
  21. private readonly children;
  22. constructor(server: Server<ListenEvents, EmitEvents, ServerSideEvents, SocketData>);
  23. /**
  24. * @private
  25. */
  26. _initAdapter(): void;
  27. emit<Ev extends EventNamesWithoutAck<EmitEvents>>(ev: Ev, ...args: EventParams<EmitEvents, Ev>): boolean;
  28. createChild(name: string): Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData>;
  29. fetchSockets(): Promise<RemoteSocket<EmitEvents, SocketData>[]>;
  30. }