}); this.wsServer.on('connection', (ws) => { const connectionId = crypto.randomBytes(8).toString('hex'); connectionIdToSocket[connectionId] = ws; ws.on('message', async (message) => { await subscriptionServer.processMessage(connectionId, message); }); ws.on('close', async () => { await subscriptionServer.disconnect(connectionId); }); ws.on('error', async () => { await subscriptionServer.disconnect(connectionId); });
this.wss.on("connection", ws => { this.onopened(this.tty._pid); ws.on("close", (code, reason) => { this.ondisconnected(code, reason); }); ws.on("message", msg => { this.tty.write(msg); }); this.tty.onData(data => { this._nextTickUpdateTtyCWD = true; this._nextTickUpdateProcess = true; try { ws.send(data); } catch (e) { // Websocket closed } }); });
constructor() { super(); this.httpServer = new HttpServer(); let self = this; this.wsServer = new WebSocket.Server({ server: this.httpServer }); this.wsServer.on('connection', function (socket) { // emit socket to outside self.emit('connection', socket); }); this.state = ST_STARTED; }
// if for some reason the server went down, restart it some seconds later WebSocketMgr.server.on('close', function close () { WebSocketMgr.server = null WebSocketUser.instances = [] })
this.wss.on("connection", ws => { this.onopened(this.tty._pid); ws.on("close", (code, reason) => { this.ondisconnected(code, reason); }); ws.on("message", msg => { this.tty.write(msg); }); this.tty.onData(data => { this._nextTickUpdateTtyCWD = true; this._nextTickUpdateProcess = true; try { ws.send(data); } catch (e) { // Websocket closed } }); });
constructor() { super(); this.httpServer = new HttpServer(); let self = this; this.wsServer = new WebSocket.Server({ server: this.httpServer }); this.wsServer.on('connection', function (socket) { // emit socket to outside self.emit('connection', socket); }); this.state = ST_STARTED; }