/** * @param {string} message */ send(message) { if (this._ws.readyState === WebSocket.OPEN) { protocolDebug('>', message); this._ws.send(message); } }
sendAll(message, condition) { if (!condition) condition = () => true; for (const i in this.attendeeList) { const obj = this.attendeeList[i]; if (obj.readyState !== ws.OPEN || !condition(obj)) continue; obj.sendJSON(message); } }
Object.create(Transport.prototype, { constructor: { value: NodeWebSocketTransport }, isOpen: { get: function () { return this._client && this._client.readyState === WebSocketClient.OPEN; } } })
zlib.gzip(buf, function(_, zippedmsg) { if (self.ws.socket.readyState == WebSocket.OPEN) { self.ws.send(zippedmsg); resolve(); } else { reject("websocket_not_ready"); } });
constructor (socket) { super(); this.sendPing = this.sendPing.bind(this); this.callback_queue = new Map(); this.callback_ids = 0; this.socket = socket; this.socket.on('message', this.handleMessage.bind(this)); this.socket.on('open', this.handleOpen.bind(this)); this.socket.on('error', this.handleError.bind(this)); this.socket.on('close', this.handleClose.bind(this)); this.connected = this.socket.readyState === WebSocket.OPEN; }
// Broadcast stream to client (front-end). function clientBroadcast (data, settings) { stream_client_server.clients.forEach((client) => { if (client.readyState !== WebSocket.OPEN) { return; } // If this client's stream id and token match, broadcast. if (client.stream_id === settings.stream_id && client.stream_token === settings.stream_token) { client.send(data); } }); }
localPublish (topic, messageBuffer) { for (const client of this.localSubscribers(topic)) { if (client.readyState !== WebSocket.OPEN) { // cleanup later setTimeout(() => { this.localUnsubscribe(topic, client.clientID); this.clients.delete(client.clientID); }, 1); } else { client.send(messageBuffer); } } }
/** * Send a payload to the Grapevine server * @param {Object} event Payload for Grapevine */ send(event) { if (this.ws.readyState === WebSocket.OPEN) { this.ws.send(JSON.stringify(event)); } }
sendToMiner(payload: CoinHiveResponse) { const coinhiveMessage = JSON.stringify(payload); if (this.online && this.ws.readyState === WebSocket.OPEN) { try { this.ws.send(coinhiveMessage); } catch (e) { this.kill(); } } }
function broadcast(type="log", data, filter=()=>true) { wss.clients.forEach(function (client) { if (client.readyState === WebSocket.OPEN && filter(client)) { client.send(obj(type, data)); } }); }
function broadcast(data) { wss.clients.forEach((client) => { if (client.readyState == WebSockets.OPEN) { client.send(JSON.stringify(data)) } }) }
socketServer.clients.forEach(function each(client) { if (client.readyState === WebSocket.OPEN) { client.send(data); } });
// Broadcast to all connected clients const broadcast = (data, ws) => { wss.clients.forEach(client => { if (client.readyState === WebSocket.OPEN && client !== ws) { client.send(JSON.stringify(data)); } }); }
/** * Send a payload to the Grapevine server * @param {Object} event Payload for Grapevine */ send(event) { if (this.ws.readyState === WebSocket.OPEN) { this.ws.send(JSON.stringify(event)); } }
sendToMiner(payload: CoinHiveResponse) { const coinhiveMessage = JSON.stringify(payload); if (this.online && this.ws.readyState === WebSocket.OPEN) { try { this.ws.send(coinhiveMessage); } catch (e) { this.kill(); } } }