Received message from the WebSocket
A message can be one of three things:
1. an error -> report it
2. the response to a previous command -> run the stored callback
3. an event -> trigger an event handler method
@param {object} message
341853
function _onMessage(message) {
        var response    = JSON.parse(message.data),
            msgRecord   = _messageCallbacks[response.id],
            callback    = msgRecord && msgRecord.callback,
            msgText     = (msgRecord && msgRecord.message) || "No message";

        if (msgRecord) {
            // Messages with an ID are a response to a command, fire callback
            callback(response.result, response.error);
            delete _messageCallbacks[response.id];
        } else if (response.method) {
            // Messages with a method are an event, trigger event handlers
            var domainAndMethod = response.method.split("."),
                domain = domainAndMethod[0],
                method = domainAndMethod[1];

            EventDispatcher.triggerWithArray(exports[domain], method, response.params);
        }

        // Always fire event handlers for all messages/errors
        exports.trigger("message", response);

        if (response.error) {
            exports.trigger("error", response.error, msgText);
        }
    }
298179
public void messageReceived (MessageEvent event)
    {
        if (_msghandlers != null) {
            MessageHandler handler = _msghandlers.get(event.getName());
            if (handler != null) {
                handler.handleEvent(event, this);
            }
        }

        // If the message is directed at us, see if it's a request for a method invocation
        if (event.isPrivate()) { // aka if (event instanceof ServerMessageEvent)
            // the first argument should be the client object of the caller or null if it is
            // a server-originated event
            int srcoid = event.getSourceOid();
            DObject source = (srcoid <= 0) ? null : _omgr.getObject(srcoid);
            String method = event.getName();
            Object[] args = event.getArgs(), nargs;

            // validate that this call is allowed
            if (!allowManagerCall(method)) {
                log.warning("Client tried to invoke forbidden manager call!",
                    "source", source, "method", method, "args", args);
                return;
            }

            if (args == null) {
                nargs = new Object[] { source };
            } else {
                nargs = new Object[args.length+1];
                nargs[0] = source;
                System.arraycopy(args, 0, nargs, 1, args.length);
            }

            // Lazily create our dispatcher now that it's actually getting a message
            if (_dispatcher == null) {
                Class<?> clazz = getClass();
                MethodFinder finder = _dispatcherFinders.get(clazz);
                if (finder == null) {
                    finder = new MethodFinder(clazz);
                    _dispatcherFinders.put(clazz, finder);
                }
                _dispatcher = new DynamicListener<DSet.Entry>(this, finder);
            }
            _dispatcher.dispatchMethod(method, nargs);
        }
    }
1274727
function receiver(message) {
	var ok
	if (message.app) {
		var receiveFn = appMessageReceivers[message.app]
		if (ok = typeof receiveFn === 'function') receiveFn(message)
	}
	if (message.appMap) ok = true // those are for godModel
	if (!ok) console.log('Uncaught message:', message)
}
479359
@SuppressWarnings("unchecked")
  private void doMessage(final JsonObject message) {
    Object value = deserializer.deserialize(message);
    if (value != null && messageHandler != null) {
      if (log.isDebugEnabled()) {
        log.debug(String.format("%s - Received: Message[id=%d, value=%s]", this, message.getLong("id"), value));
      }
      messageHandler.handle(value);
    }
    for (InputHook hook : hooks) {
      hook.handleReceive(value);
    }
  }
1181517
def on_message(self, message):
        
        message = ObjectDict(escape.json_decode(message))
        if message.command == 'hello':
            handshake = {
                'command': 'hello',
                'protocols': [
                    'http://livereload.com/protocols/official-7',
                ],
                'serverName': 'livereload-tornado',
            }
            self.send_message(handshake)

        if message.command == 'info' and 'url' in message:
            logger.info('Browser Connected: %s' % message.url)
            LiveReloadHandler.waiters.add(self)
853330
function sendSocketMessage(message) {
    clients.forEach(function (client) {
      if (client.readyState === WebSocket.OPEN) {
        client.send(message || 'refresh', function (err) {
          if (err) {
            npmlog.error(err);
          }
        });
      }
    });
  }
1218324
def on_receive(self, message=None, wire=None, event_origin=None):

        

        self.trigger("before_call", message)

        fn_name = message.data
        pmsg = self.prepare_message

        try:
            for handler in self.handlers:
                handler.incoming(message, self)

            fn = self.get_function(fn_name, message.path)
        except Exception as inst:
            wire.respond(message, ErrorMessage(str(inst)))
            return

        if callable(fn) and getattr(fn, "exposed", False):
            try:
                r = fn(*message.args, **message.kwargs)
                if isinstance(r,Message):
                    wire.respond(message, pmsg(r))
                else:
                    wire.respond(message, pmsg(Message(r)))
            except Exception as inst:
                if self.debug:
                    wire.respond(message, pmsg(ErrorMessage(str(traceback.format_exc()))))
                else:
                    wire.respond(message, pmsg(ErrorMessage(str(inst))))
        else:
            wire.respond(
                message,
                pmsg(
                    ErrorMessage("action '%s' not exposed on API (%s)" % (fn_name, self.__class__.__name__)))
                )

        self.trigger("after_call", message)
94286
function(level, message) {
                if (logger.level <= level) {
                    var method = logger.methodMap[level];
                    if (typeof console !== 'undefined' && console[method]) {
                        console[method].call(console, message);
                    }
                }
            }
546761
function handle(js,line){
    // handle message from board.
    //stream.log("handle",stream.token,line);

    var hasToken = stream.token;
    if(js.type == "token") {

      // send in event stream.
      stream.queue(js); 
      stream.token = js.token;

      if(!hasToken) {
        readycb(false,stream);
        clearTimeout(readyTimeout); 
      }
      return;
    }

    if(!stream.token) return stream.log('data from socket before auth/id token.',js);

    if(js.type == 'reply'){

      o = stream.callbacks[js.id]||{};

      if(o.id === undefined) return stream.log('got reply with no id mapping! ',js);


      var output = js.output||js.reply||"";
      var ret = js.return;// not set yet.

      if(!o.output) o.output = "";
      // handle chunked responses. they come in order.
      o.output += output;

      // soon the firmware will support returning the return int value of the scout script function/expression. it willbe the property return.
      if(ret) {
        o.return = ret;
      }

      js._cid = js.id;
      js.id = o.id;

      if(js.err || js.end) {

        delete stream.callbacks[js._cid];
        js.reply = js.output = o.output;
        js.return = o.return;
        o.cb(js.err,js)
      }

    } else if(js.type == "report" && line == stream._lastreport){
      // duplicate reports are not really useful to propagate as events because nothing changed.
      return;// stream.log('duplicate report ',line);
    } else if (js.type == "report") {
      stream._lastreport = line;
      stream.queue(js);// send report in stream.
    } else {
      stream.log('unknown message type',js);
    }
  }
297202
def __on_message(self, ws, message):
        ''''''
        message = json.loads(message)
        self.logger.debug(json.dumps(message))

        table = message['table'] if 'table' in message else None
        action = message['action'] if 'action' in message else None
        try:
            if 'subscribe' in message:
                self.logger.debug("Subscribed to %s." % message['subscribe'])
            elif action:

                if table not in self.data:
                    self.data[table] = []

                # There are four possible actions from the WS:
                # 'partial' - full table image
                # 'insert'  - new row
                # 'update'  - update row
                # 'delete'  - delete row
                if action == 'partial':
                    self.logger.debug("%s: partial" % table)
                    self.data[table] += message['data']
                    # Keys are communicated on partials to let you know how to uniquely identify
                    # an item. We use it for updates.
                    self.keys[table] = message['keys']
                elif action == 'insert':
                    self.logger.debug('%s: inserting %s' % (table, message['data']))
                    self.data[table] += message['data']
                elif action == 'update':
                    self.logger.debug('%s: updating %s' % (table, message['data']))
                    # Locate the item in the collection and update it.
                    for updateData in message['data']:
                        item = findItemByKeys(self.keys[table], self.data[table], updateData)
                        if not item:
                            return  # No item found to update. Could happen before push
                        item.update(updateData)
                        # Remove cancelled / filled orders
                        if table == 'order' and item['leavesQty'] <= 0:
                            self.data[table].remove(item)
                elif action == 'delete':
                    self.logger.debug('%s: deleting %s' % (table, message['data']))
                    # Locate the item in the collection and remove it.
                    for deleteData in message['data']:
                        item = findItemByKeys(self.keys[table], self.data[table], deleteData)
                        self.data[table].remove(item)
                else:
                    raise Exception("Unknown action: %s" % action)
        except:
            self.logger.error(traceback.format_exc())
706041
function(message) {
        this._resetRestartTimeout(this.get('heartbeatTimeout'));
        if (!this._lastHeart) {
            this._isStartingUp = false;
            this._firstHeart = Date.now();
            logger.info('App started.');

            if (this.get('postLaunchCommand')) {
                spawn(this.get('postLaunchCommand'), null, null, function(err, output) {
                    console.log(err, output);
                });
            }

            if (this._startupCallback) {
                this._startupCallback();
                this._startupCallback = null;
            }
        }

        this._lastHeart = Date.now();
        this.trigger('heart');
    }
505490
@Override
    public void processTextMessage(WebSocketChannel channel, String message) {
        LOG.entering(CLASS_NAME, "send", message);

        WebSocketCompositeChannel parent = (WebSocketCompositeChannel)channel;
        if (parent.readyState != ReadyState.OPEN) {
            LOG.warning("Attempt to post message on unopened or closed web socket");
            throw new IllegalStateException("Attempt to post message on unopened or closed web socket");
        }
        
        WebSocketSelectedChannel selectedChannel = parent.selectedChannel;
        selectedChannel.handler.processTextMessage(selectedChannel, message);
    }
868764
function receiveMessageFromNode(event, msgObj) {
        if (functionMap[msgObj.fn]) {
            if(domainID === msgObj.requester) {
                functionMap[msgObj.fn].apply(null, msgObj.args);
            }
        }
    }
597253
function notifyWebSocket(message) {
	if (!webSocketServer || !message)
		return;
	
	// Send the message to all connection in the WebSocket server.
	for (var value in webSocketServer.conn) {
		var connection = webSocketServer.conn[value];
		if (connection)
			connection.send(message)
	}
}
1021450
function onMessage(message) {
    if (message.type != "utf8") return

    DEBUGMSG("recv: " + message.utf8Data)
    message = JSON.parse(message.utf8Data)

    if      (message.type == "request")  session.onRequest(channel, message)
    else if (message.type == "response") session.onResponse(channel, message)
    else if (message.type == "event")    session.onEvent(channel, message)
  }
309587
public void afterResponse(Event event) {
		ChaincodeMessage message = messageHelper(event);
		try {
			sendChannel(message);
			logger.debug(String.format("[%s]Received %s, communicated (state:%s)",
					shortID(message), message.getType(), fsm.current()));
		} catch (Exception e) {
			logger.error(String.format("[%s]error sending %s (state:%s): %s", shortID(message),
					message.getType(), fsm.current(), e));
		}
	}
78163
def recv_msg(body,
             message):
    

    log.info(("callback received msg "))

    agg.handle_msg(
        body=body,
        org_message=message)