static dump() { Object.keys(_routerInstances).forEach(id => { const router = _routerInstances[id] for (const hid in router.hubs) { debug(`Router[${id}] <----> Hub[${hid}]`) } }) }
link(hub) { this.hubs[hub.id] = hub; hub.router = this; }
client.__defineGetter__('hubs', function () { var ret = [], x = 0; for (h in _client.hubs) { ret[x++] = h; } return ret; });
/** * @constructor * @param {Object} obj The object passed to constructor */ constructor(obj) { super(obj); if (obj === undefined || obj === null) return; this.mode = this.constructor.getValue(obj.mode); this.hubs = this.constructor.getValue(obj.hubs); this.subnets = this.constructor.getValue(obj.subnets); }
private _pushMessage(message: Message) { message.destination.forEach(dest => { if (this.hubs[dest.hubId]) { if (Array.isArray(dest.terminalId) && dest.terminalId.length > 0) { dest.terminalId.forEach(terminal => { this.hubs[dest.hubId].pushToTerminal(terminal, message) }) } else if (typeof dest.terminalId === 'string' && dest.terminalId) { this.hubs[dest.hubId].pushToTerminal(dest.terminalId, message) } else { this.hubs[dest.hubId].broadcast(message) } } else { debug(`Error: Hub [' + dest.hubId + '] not found`) } }) message.destroy() }
static check() { Object.keys(_routerInstances).forEach(id => { if (Object.keys(_routerInstances[id].hubs).length === 0) { console.error(`Error: Router[${id}] do not has any hub.`) } }) }
makeRequest(config.hubs, env, token, function (body) { onsuccess(body.data); });
link(hub: Hub) { this.hubs[hub.id] = hub hub.router = this }
static check() { Object.keys(_routerInstances).forEach(id => { if (Object.keys(_routerInstances[id].hubs).length === 0) { console.error(`Error: Router[${id}] do not has any hub.`); } }); }
static dump() { Object.keys(_routerInstances).forEach(id => { const router = _routerInstances[id]; for (const hid in router.hubs) { debug(`Router[${id}] <----> Hub[${hid}]`); } }); }
_pushMessage(message) { message.destination.forEach(dest => { if (this.hubs[dest.hubId]) { if (Array.isArray(dest.terminalId) && dest.terminalId.length > 0) { dest.terminalId.forEach(terminal => { this.hubs[dest.hubId].pushToTerminal(terminal, message); }); } else if (typeof dest.terminalId === 'string' && dest.terminalId) { this.hubs[dest.hubId].pushToTerminal(dest.terminalId, message); } else { this.hubs[dest.hubId].broadcast(message); } } else { debug(`Error: Hub [' + dest.hubId + '] not found`); } }); message.destroy(); }