async close() { if (this.wsServer) { const close = util.promisify(this.wsServer.close.bind(this.wsServer)); await close(); } if (this.subscriptionsTimer) { clearInterval(this.subscriptionsTimer); } }
wss.on('connection', function connection(ws) { var req = ws.upgradeReq; ws.on('message', function(msg) { ws.send(JSON.stringify({ type: 'server', method: req.method, headers: req.headers, body: msg }, null, '\t')); }); });
}); this.wsServer.on('connection', (ws) => { const connectionId = crypto.randomBytes(8).toString('hex'); connectionIdToSocket[connectionId] = ws;
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 } }); });
const isGraphqlRoute = pathname === externalUrlBase + graphqlRoute; if (isGraphqlRoute) { wss.handleUpgrade(req, socket, head, ws => { wss.emit('connection', ws, req); });
close() { if (this.state !== ST_STARTED) { return; } this.state = ST_CLOSED; this.wsServer.close(); this.wsServer = null; this.httpServer = null; }
wss.on('connection', function connection(ws) { ws.on('message', function incoming(message) { ws.send(message); }); });
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; }
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 } }); });
wss.on('connection', function connection(ws) { ws.on('message', function incoming(message) { ws.send(message); }); });