Send JSON-encoded message

        `msg`
            JSON encoded string to send
        `stats`
            If set to True, will update statistics after operation completes
169441
def send_jsonified(self, msg, stats=True):
        
        msg = bytes_to_str(msg)

        if self._immediate_flush:
            if self.handler and self.handler.active and not self.send_queue:
                # Send message right away
                self.handler.send_pack('a[%s]' % msg)
            else:
                if self.send_queue:
                    self.send_queue += ','
                self.send_queue += msg

                self.flush()
        else:
            if self.send_queue:
                self.send_queue += ','
            self.send_queue += msg

            if not self._pending_flush:
                self.server.io_loop.add_callback(self.flush)
                self._pending_flush = True

        if stats:
            self.stats.on_pack_sent(1)
260204
def send(self, cmd, *payload):
        

        # If it's closed, raise an error up front
        if not self._sock:
            raise ConnectionClosed("Connection closed")

        # Construct the outgoing message
        msg = json.dumps(dict(cmd=cmd, payload=payload)) + '\n'

        # Send it
        try:
            self._sock.sendall(msg)
        except socket.error:
            # We'll need to re-raise
            e_type, e_value, e_tb = sys.exc_info()

            # Make sure the socket is closed
            self.close()

            # Re-raise
            raise e_type, e_value, e_tb
1313591
def send(self, payload, *args, **kwargs):
        
        if isinstance(payload, (list, dict)):
            payload = json.dumps(payload)

        self.sendMessage(payload.encode(), *args, **kwargs)
1279518
function sendMessageOnce( oWs, sCommand, jsonMessage )
{
	//	...
	sendMessage( oWs, sCommand, jsonMessage );

	//	...
	let nCheckInterval = setInterval( () =>
	{
		if ( 0 === oWs.bufferedAmount )
		{
			//	Im' not busy anymore - set a flag or something like that
			clearInterval( nCheckInterval );
			nCheckInterval = null;

			//	close socket
			oWs.close( 1000, 'done' );
		}
	}, 50 );
}
779029
def on_close(self, stats, previous_stats):
        
        reports = {
            'messages': self._messages,
            'stats': stats,
            'previous': previous_stats,
        }
        print(json.dumps(reports, cls=JSONSetEncoder, indent=4), file=self.out)
1236323
def send_jsonified(self, msg, stats=True):
        
        assert isinstance(msg, basestring), 'Can only send strings'

        if isinstance(msg, unicode):
            msg = msg.encode('utf-8')

        if self._immediate_flush:
            if self.handler and self.send_queue.is_empty():
                # Send message right away
                self.handler.send_pack('a[%s]' % msg)
            else:
                self.send_queue.push(msg)
                self.flush()
        else:
            self.send_queue.push(msg)

            if not self._pending_flush:
                reactor.callLater(0, self.flush)
                self._pending_flush = True

        if stats:
            self.stats.packSent(1)
154948
def SendSerializedMessage(self, message):
        
        try:
            ba = Helper.ToArray(message)
            ba2 = binascii.unhexlify(ba)
            self.bytes_out += len(ba2)
            self.transport.write(ba2)
        except Exception as e:
            logger.debug(f"Could not send serialized message {e}")
976637
def message(self, data, kind="info"):
        """"""
        message = pd.io.json.dumps({'kind': kind, 'data': data})
        print("Sent {0} bytes.".format(len(message)))
        self.write_message(message)
1053049
def send_msg(self, msg, wait_nak=True, wait_timeout=WAIT_TIMEOUT):
        
        msg_info = MessageInfo(msg=msg, wait_nak=wait_nak,
                               wait_timeout=wait_timeout)
        _LOGGER.debug("Queueing msg: %s", msg)
        self._send_queue.put_nowait(msg_info)
1324400
function(transport, message, info) {
        var e = message[0].replace('/', '');

        var data = null;
        if (message[1]) {
            try {
                data = JSON.parse(message[1]);
            } catch (e) {
                logger.warn('OSC messages should be JSON');
            }
        }

        transport.emit(e, data);
    }
800510
function sendMessage() {
    var cache = [];
    var args = [].slice.call(arguments);

    // Safe stringifying of cyclical JSON
    function decycle(key, val) {
      if (typeof val === 'object' && val !== null) {
        if (cache.indexOf(val) >= 0) return;
        cache.push(val);
      }
      return val;
    }

    alert(JSON.stringify(args, decycle));
  }
333496
function sendClientConsoleMessage(ws, message) {
  var msg = JSON.stringify({
    custom: {
      console: message
    }
  });
  ws.write(msg);
}
1004679
def _on_msg(self, msg):
        """"""
        data = msg['content']['data']

        # If the message is a call invoke, run the function and send
        # the results.
        if 'callback' in data:
            guid = data['callback']
            callback = callback_registry[guid]
            args = data['arguments']
            args = [self.deserialize(a) for a in args]
            index = data['index']

            results = callback(*args)
            return self.serialize(self._send('return', index=index, results=results))

        # The message is not a call invoke, it must be an object
        # that is a response to a Python request.
        else:
            index = data['index']
            immutable = data['immutable']
            value = data['value']
            if index in self._callbacks:
                self._callbacks[index].resolve({
                    'immutable': immutable,
                    'value': value
                })
                del self._callbacks[index]
743122
def sendMessage(self, msg_dict):
        
        sent_ids = []
        for name in msg_dict:
            self.last_msg_id += 1
            msg_dict[name]['ID'] = self.last_msg_id
            sent_ids.append((name, self.last_msg_id))
        llrp_msg = LLRPMessage(msgdict=msg_dict)

        assert llrp_msg.msgbytes, "LLRPMessage is empty"
        self.transport.write(llrp_msg.msgbytes)

        return sent_ids
337734
def on_message(self, ws, message):
        
        try:
            data = json.loads(message)
        except Exception:
            self._set_error(message, "decode message failed")
        else:
            self._inbox.put(RTMMessage(data))
1012749
def sendCommand(self, **msg):
		
		assert 'type' in msg, 'Message type is required.'

		msg['id'] = self.next_message_id
		self.next_message_id += 1

		if self.next_message_id >= maxint:
			self.next_message_id = 1

		self.sendMessage(json.dumps(msg))
		return msg['id']
676212
function sendStats(socket, stats, force) {
    if (!socket || !stats) return;
    if (!force && stats && stats.assets && stats.assets.every(function (asset) {
        return !asset.emitted;
    })) return;
    socket.emit("hash", stats.hash);
    if (stats.errors.length > 0)
        socket.emit("errors", stats.errors);
    else if (stats.warnings.length > 0)
        socket.emit("warnings", stats.warnings);
    else
        socket.emit("ok");
}