mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
This upgrades prettier to 2.2.0 to gain support for TypeScript's new type-only-imports feature.
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { Namespace } from "./namespace";
|
|
import type { Server } from "./index";
|
|
|
|
export class ParentNamespace extends Namespace {
|
|
private static count: number = 0;
|
|
private children: Set<Namespace> = new Set();
|
|
|
|
constructor(server: Server) {
|
|
super(server, "/_" + ParentNamespace.count++);
|
|
}
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
_initAdapter(): void {
|
|
/* no-op */
|
|
}
|
|
|
|
public emit(ev: string | Symbol, ...args: [...any]): true {
|
|
this.children.forEach((nsp) => {
|
|
nsp._rooms = this._rooms;
|
|
nsp._flags = this._flags;
|
|
nsp.emit(ev, ...args);
|
|
});
|
|
this._rooms.clear();
|
|
this._flags = {};
|
|
|
|
return true;
|
|
}
|
|
|
|
createChild(name: string): Namespace {
|
|
const namespace = new Namespace(this.server, name);
|
|
namespace._fns = this._fns.slice(0);
|
|
this.listeners("connect").forEach((listener) =>
|
|
namespace.on("connect", listener as (...args: any[]) => void)
|
|
);
|
|
this.listeners("connection").forEach((listener) =>
|
|
namespace.on("connection", listener as (...args: any[]) => void)
|
|
);
|
|
this.children.add(namespace);
|
|
this.server._nsps.set(name, namespace);
|
|
return namespace;
|
|
}
|
|
}
|