Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

36 lines
1.2 KiB

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParentNamespace = void 0;
const namespace_1 = require("./namespace");
class ParentNamespace extends namespace_1.Namespace {
constructor(server) {
super(server, "/_" + ParentNamespace.count++);
this.children = new Set();
}
_initAdapter() { }
emit(...args) {
this.children.forEach(nsp => {
nsp._rooms = this._rooms;
nsp._flags = this._flags;
nsp.emit.apply(nsp, args);
});
this._rooms.clear();
this._flags = {};
return true;
}
createChild(name) {
const namespace = new namespace_1.Namespace(this.server, name);
namespace._fns = this._fns.slice(0);
this.listeners("connect").forEach(listener =>
// @ts-ignore
namespace.on("connect", listener));
this.listeners("connection").forEach(listener =>
// @ts-ignore
namespace.on("connection", listener));
this.children.add(namespace);
this.server._nsps.set(name, namespace);
return namespace;
}
}
exports.ParentNamespace = ParentNamespace;
ParentNamespace.count = 0;