callback executes when actor receives a message from a subscribed channel
 and parses the message using JSON.parse and dispatches the parsed
 message to the original actor that made the connection

 @param [JSON] data

 @return [void]

 @api public
550439
def on_message(data)
      message = JSON.parse(data)
      log_debug("#{@actor.class} received JSON  #{message}")
      if @actor.respond_to?(:async)
        @actor.async.on_message(message)
      else
        @actor.on_message(message)
      end
    end
1178394
def analog_callback(self, data):
        
        reply = json.dumps({"method": "analog_message_reply", "params": [data[0], data[1]]})
        asyncio.ensure_future(self.websocket.send(reply))
614261
function onMessage(data) {
    if (data.type == "utf8") {
        message = JSON.parse(data.utf8Data);
        switch (message.command) {
            case "setJoints":
                console.log("Client has request to add joints: " + message.data);
                nuimotion.jointsTracking = message.data;
                break;

            case "addListener":
                console.log("Client has request to add events: " + message.data);
                if (!nuimotion._eventCallbackDict[message.data]) {
                    nuimotion.addListener(message.data, onEvent);
                }
                break;

            case "addGesture":
                console.log("Client has request to add gestures: " + message.data);
                if (!nuimotion._gestureCallbackDict[message.data]) {
                    nuimotion.addGesture(message.data, onEvent);
                }
                break;
        }
    }
}
641530
function onBytesMessage(peer,data)
    {
        var arr = bufferToArray(scope._servConn.byteType,data);

        if(arr)
        {
            if(scope._servConn.rtcFallback == true)
            {
                arr = arr.slice(0,arr.length-2);
            }
            scope.dispatchEvent("peerMessage",{message:arr,id:peer.id,rtc:peer.rtcId,array:true,fallback:false});
        }
    }
477682
async def on_data(self, data):
        
        self._receive_buffer += data

        # Schedule new timeout event.
        if self._ping_checker_handle:
            self._ping_checker_handle.cancel()

        # create a task for the ping checker
        self._ping_checker_handle = self.eventloop.create_task(
            self._perform_ping_timeout(self.PING_TIMEOUT))

        while self._has_message():
            message = self._parse_message()
            self.eventloop.create_task(self.on_raw(message))
323789
function(data, callback) {
    var json
    try {
        json = JSON.parse(data)
    } catch (exc) {
        return callback(exc)
    }
    callback(null, json)
}
1111553
def _receive_callback(self, raw_message):
        """"""
        message = self.backend.message_to_python(raw_message)
        if self.auto_ack and not message.acknowledged:
            message.ack()
        try:
            decoded = message.decode()
        except Exception, exc:
            if not self.on_decode_error:
                raise
            self.on_decode_error(message, exc)
        else:
            self.receive(decoded, message)
1106999
function ondatachannel(e)
    {
        if(e)
        {
            scope._data = e.channel;
        }
        else
        {
            scope._data = scope._conn.createDataChannel("data");
        }

        scope._data.onopen = function()
        {
            if(scope._data)
            {
                if(scope._data.readyState == "open")
                {
                    if(scope.onChannelState)
                    {
                        scope.onChannelState(scope,'open');
                    }
                }
            }
        };
        scope._data.onmessage = function(e)
        {
            if(e.data instanceof ArrayBuffer)
            {
                if(scope.onBytesMessage)
                {
                    scope.onBytesMessage(scope,e.data);
                }
            }
            else
            {
                if(scope.onMessage)
                {
                    var char = Number(e.data[0]);

                    if(char == MessageType.MESSAGE)
                    {
                        scope.onMessage(scope,JSON.parse(e.data.substring(1,e.data.length)));
                    }
                    else
                    {
                        scope.onMessage(scope,e.data);
                    }
                }
            }
        }
        
        scope._data.onclose = function(e)
        {
            if(scope.onChannelState)
            {
                scope.onChannelState(scope,'closed');
            }
        }
        scope._data.onerror = function(e)
        {
            if(scope.onError)
            {
                scope.onError(e);
            }
        }
    }
1372658
def onConnect(self, client, userdata, flags, rc):
        
        for sub in self.subsciption:
            (result, mid) = self.client.subscribe(sub)
590120
function (data, callback) {
    if (typeof callback !== 'function') {
        this.debug("Registering dummy callback, because a response message is expected");
    } else {
        this.debug("Registering callback");
    }
    this.waitingCallbacks.push(callback);
    send.call(this, data);
}
1133666
function( socket ) {
    var self = this;
    this.buffers = [];
    this.readers = [];
    this.length = 0;
    this.socket = socket;

    // Register the data callback to receive data from Mumble server.
    socket.on( 'data', function( data ) {
        self.receiveData( data );
    } );
}
294647
function receive(message) {
        message = JSON.parse(message);
        _debug("receive: parsed message", message);

        if (!receivers[message.type])
            return; // ignore bad message types
        if (!hasLocal(message.to)) {
            if (typeof options.onmessagelost === "function") {
                options.onmessagelost(message);
            }
            // ignore messages to non-existant or forgotten promises
            return;
        }
        receivers[message.type](message);
    }
1004573
function onData( subtrahend ) {
		/**
		* FUNCTION: onData( newVal, encoding, clbk )
		*	Data event handler. Performs subtraction.
		*
		* @private
		* @param {Number} newVal - streamed data value
		* @param {String} encoding
		* @param {Function} clbk - callback to invoke after performing subtraction. Function accepts two arguments: [ error, chunk ].
		*/
		return function onData( newVal, encoding, clbk ) {
			clbk( null, newVal-subtrahend );
		}; // end FUNCTION onData()
	}
1122032
function onData(data) {

		data = data.toString("ascii");
		bufferedData += data;

		if (debug) console.log("Server: " + util.inspect(data));

		if (checkResp === true) {

			if (bufferedData.substr(0, 3) === "+OK") {

				checkResp = false;
				response = true;

			} else if (bufferedData.substr(0, 4) === "-ERR") {

				checkResp = false;
				response = false;

			// The following is only used for SASL
			} else if (multiline === false) {

				checkResp = false;
				response = true;

			}
		}

		if (checkResp === false) {

			if (multiline === true && (response === false || bufferedData.substr(bufferedData.length-5) === "\r\n.\r\n")) {

				// Make a copy to avoid race conditions
				var responseCopy = response;
				var bufferedDataCopy = bufferedData;

				response = null;
				checkResp = true;
				multiline = false;
				bufferedData = "";

				callback(responseCopy, bufferedDataCopy);

			} else if (multiline === false) {

				// Make a copy to avoid race conditions
				var responseCopy = response;
				var bufferedDataCopy = bufferedData;

				response = null;
				checkResp = true;
				multiline = false;
				bufferedData = "";

				callback(responseCopy, bufferedDataCopy);

			}
		} 
	}
1360666
function onMessage(message) {

    if (!session._channel) {
      DEBUG("channel connection message received")
      if (message.type != "response") return
      if (message.name != "connect") return
      if (message.from != "server") return
      if (message.id   != "0") return

      DEBUG("channel connection message accepted")

      session._channel = channel
      cb(null, session)
      return
    }

    var agent

    if (message.to == "server") {
      if (message.type == "request")     agent = session._ragentServer
    }

    else if (message.from == "server") {
      if (message.type == "response")    agent = session._ragentServer
      if (message.type == "event")       agent = session._ragentServer
    }

    else if (message.type == "request")  agent = session._agents.get(message.to)
    else if (message.type == "response") agent = session._ragents.get(message.from)
    else if (message.type == "event")    agent = session._ragents.get(message.from)

    if (!agent) return

    if      (message.type == "request")  agent._onRequest(message)
    else if (message.type == "response") agent._onResponse(message)
    else if (message.type == "event")    agent._onEvent(message)
  }
1000086
def receive_message(self, message, data):
        
        if self._socket_client.is_stopped:
            return True

        if data[MESSAGE_TYPE] == TYPE_CLOSE:
            # The cast device is asking us to acknowledge closing this channel.
            self._socket_client.disconnect_channel(message.source_id)

            # Schedule a status update so that a channel is created.
            self._socket_client.receiver_controller.update_status()

            return True

        return False
923613
def received(self, data):
        
        self.logger.debug('Data received: {}'.format(data))

        message_type = None

        if 'type' in data:
            message_type = data['type']

        if message_type == 'confirm_subscription':
            self._subscribed()
        elif message_type == 'reject_subscription':
            self._rejected()
        elif self.receive_callback is not None and 'message' in data:
            self.receive_callback(data['message'])
        else:
            self.logger.warning('Message type unknown. ({})'.format(message_type))