ws.on('open', function open() { if (/checkStatusCode/.test(url)) { if (done) { return; } done = true; callback && callback('checkStatusCode'); exit(); } else { ws.send('something'); } });
/** * @param {!WebSocket} ws */ constructor(ws) { this._ws = ws; this._handler = null; this._messageListener = this._messageReceived.bind(this); this._ws.on('message', this._messageListener); }
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 } }); });
}); 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); });
ws.on('message', function(data) { if (done) { return; } done = true; callback && callback(JSON.parse(data)); exit(); });
ws.on('message', (msg) => { const channel = execChannels[msg.slice(0, 1)] const message = Buffer.from(msg.slice(1), 'base64').toString('ascii') }) ws.on('error', (err) => { err.messages = messages cb(err, messages) }) ws.on('close', (code, reason) => cb(null, { messages, body: messages.map(({ message }) => message).join(''),
ws.on('open', function open() { start = Date.now(); run(); });
ws.on('message', function(data, flags) { // flags.binary will be set if a binary data is received. // flags.masked will be set if the data was masked. run(); });
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 } }); });
ws.on('message', function(data, flags) { // flags.binary will be set if a binary data is received. // flags.masked will be set if the data was masked. run(); });
ws.on('open', function open() { start = Date.now(); run(); });