Got a message from the client
972076
def on_message(self, sender, content):
        
        try:
            message = json.loads(content)

        except (ValueError, TypeError) as ex:
            logging.error("Not a valid JSON string: %s", ex)
            return

        try:
            # Check the replied message
            reply_uid = message['reply-to']
            reply_level = message['reply-level']

        except KeyError:
            # Got a new message
            logging.info("Got message %s from %s", message['content'], sender)

            # Notify listeners
            self.__pool.enqueue(self._notify_listeners, sender, message)

        else:
            # Got a reply
            try:
                level, callback = self.__callbacks[reply_uid]

            except KeyError:
                # Nobody to callback...
                pass

            else:
                if level == reply_level:
                    # Match
                    try:
                        callback(sender, message['payload'])
                    except Exception as ex:
                        logging.exception("Error notifying sender: %s", ex)
1019481
def new_message(cls, from_user, to_users, subject, content):
        
        thread = Thread.objects.create(subject=subject)
        for user in to_users:
            thread.userthread_set.create(user=user, deleted=False, unread=True)
        thread.userthread_set.create(user=from_user, deleted=True, unread=False)
        msg = cls.objects.create(thread=thread, sender=from_user, content=content)
        message_sent.send(sender=cls, message=msg, thread=thread, reply=False)
        return msg
1013458
function() {
      var delay = Math.random() * 20000;
      var sendTopic = allTopics[Math.floor(Math.random() * allTopics.length)];
      var sendCallback = function(err, msg) {
        if (err) {
          console.error('Problem with send request: ' + err.toString());
          process.exit(0);
        } else {
          if (messageCount === 0) {
            console.log('Sending messages');
          }
          ++messageCount;
          if (messageCount % 10 === 0) {
            console.log('Sent ' + messageCount + ' messages');
          }
        }
      };

      setTimeout(function() {
        var start = Math.floor(Math.random() * (loremIpsumWords.length - 15));
        var end = start + 5 + Math.floor(Math.random() * 10);
        var message =
            loremIpsum.substring(loremIpsumWords[start], loremIpsumWords[end]);
        client.send(sendTopic, message, sendCallback);
        sendMessages();
      },delay);
    }
975276
def message(text, options = {}, env = :prod, type = :normal)
      if type == :normal
        data = normal_notification(text, options)
      elsif type == :silent
        data = silent_notification(text, options)
      elsif type == :nosound
        data = nosound_notification(text, options)
      end
      return dev_json(data) if env == :dev
      prod_json(data)
    end
1170118
function Message(data, source){
	source = source || {}
	this.data = data
	this.key = source.key
	this.sourceChannel = source.name
}
1285866
function message(violation, suggestion, condition, joiner) {
  var reason =
    join(quotation(violation, '`'), joiner) +
    ' may be insensitive' +
    (condition ? ', ' + condition : '') +
    ', '

  if (suggestion) {
    reason += 'use ' + join(quotation(suggestion, '`'), joiner) + ' instead'
  } else {
    reason += 'try not to use it'
  }

  return reason
}
693661
function (ws, message) {
  let clientMessage;

  try {
    clientMessage = JSON.parse(message);
    /* jshint ignore:start */
    if (_.get(clientMessage, 'type') === 'message') {
      ws.send(JSON.stringify({
        ok: true,
        reply_to: _.get(clientMessage, 'id'),
        ts: Date.now(),
        message: _.get(clientMessage, 'text', message),
        type: _.get(clientMessage, 'type', 'message'),
        user: _.get(clientMessage, 'user', 'U1234567'),
        channel: _.get(clientMessage, 'channel', 'C1234567'),
      }));
    }
    /* jshint ignore:end */
  } catch (err) {
    logger.info('Invalid socket data ', message);
  }
}
826426
function Message (data, headers, deliveryInfo) {
        assert.object(data);
        assert.object(headers);
        assert.object(deliveryInfo);

        this.data = Message.factory(data, deliveryInfo.type);
        this.headers = headers;
        this.deliveryInfo = deliveryInfo;
    }
958713
function _onInboxMessage (sender, _, msgBuffer) {
    let message = JSON.parse(msgBuffer)
    masterBroker.setIP(message.toAddress)

    switch (message.type) {
      case 'voteRequest':
        debug(`sending vote to ${node.name === message.from ? 'myself' : message.from}`)
        _inbox.send([sender, _, JSON.stringify({
          id: _advertiseId || node.id,
          name: node.name,
          endpoints: masterBroker.endpoints,
          isMaster: masterBroker.isMaster,
          candidate: !_advertiseId
        })])
        break
      case 'masterRequest':
        let connectedMaster = node.master
        if (connectedMaster) {
          debug(`sending master coordinates to ${message.from}`)
          _inbox.send([sender, _, JSON.stringify(connectedMaster)])
        } else {
          debug(`unable to send master coordinates to ${message.from}`)
          _inbox.send([sender, _, JSON.stringify(false)])
        }
        break
      case 'masterElected':
        _inbox.send([sender, _, ''])
        debug(`received notice of master election: ${message.data.name}`)
        resolver.emit('newmaster', message.data)
    }
  }
54607
function readNotifyUserMessage(message, tokens) {
	message.userName = protocol.decodeString(tokens[1]);
	message.sessionId = protocol.decodeString(tokens[3]);
	message.userMessage = protocol.decodeString(tokens[5]);
}
1119931
function(msg, node, RED, io, ioNs, log) {
        node.rcvMsgCount++
        log.verbose(`[${node.url}] msg received via FLOW. ${node.rcvMsgCount} messages received`, msg)

        // If the input msg is a uibuilder control msg, then drop it to prevent loops
        if ( msg.hasOwnProperty('uibuilderCtrl') ) return null

        //setNodeStatus({fill: 'yellow', shape: 'dot', text: 'Message Received #' + node.rcvMsgCount}, node)

        // Remove script/style content if admin settings don't allow
        if ( node.allowScripts !== true ) {
            if ( msg.hasOwnProperty('script') ) delete msg.script
        }
        if ( node.allowStyles !== true ) {
            if ( msg.hasOwnProperty('style') ) delete msg.style
        }

        // pass the complete msg object to the uibuilder client
        // TODO: This should have some safety validation on it!
        if (msg._socketId) {
            log.debug(`[${node.url}] msg sent on to client ${msg._socketId}. Channel: ${node.ioChannels.server}`, msg)
            ioNs.to(msg._socketId).emit(node.ioChannels.server, msg)
        } else {
            log.debug(`[${node.url}] msg sent on to ALL clients. Channel: ${node.ioChannels.server}`, msg)
            ioNs.emit(node.ioChannels.server, msg)
        }

        if (node.fwdInMessages) {
            // Send on the input msg to output
            node.send(msg)
            log.debug(`[${node.url}] msg passed downstream to next node`, msg)
        }

        return msg
    }
961466
def clientCutText(self, message):
        
        self.transport.write(pack("!BxxxI", 6, len(message)) + message)
246722
def response(self, beacon_config, request, client_address):
		
		return self._message(beacon_config, invert_hello=self.__invert_hello)
825772
def announce(self, number):
        
        self.client.publish(self.keys.internal, self.keys.key(number))
        self.message('{} granted'.format(number))
1187165
async def handle_client_message(self, client_addr, message):
        """"""

        # Verify that the client is registered
        if message.__class__ != ClientHello and client_addr not in self._registered_clients:
            await ZMQUtils.send_with_addr(self._client_socket, client_addr, Unknown())
            return

        message_handlers = {
            ClientHello: self.handle_client_hello,
            ClientNewJob: self.handle_client_new_job,
            ClientKillJob: self.handle_client_kill_job,
            ClientGetQueue: self.handle_client_get_queue,
            Ping: self.handle_client_ping
        }
        try:
            func = message_handlers[message.__class__]
        except:
            raise TypeError("Unknown message type %s" % message.__class__)
        self._create_safe_task(func(client_addr, message))
147875
def success(message)
      puts message.prepend('➜ ').colorize(:light_green)
    end
1365634
def received_message(self, msg):
        
        logger.debug("Received message: %s", msg)
        if msg.is_binary:
            raise ValueError("Binary messages not supported")
        resps = json.loads(msg.data)

        cmd_group = _get_cmds_id(*resps)
        if cmd_group:
            (cmds, promise) = self._cmd_groups[cmd_group]
            promise.fulfill((cmds, resps))
        else:
            try:
                self.received_unsolicited(resps)
            except:
                logger.exception("Error in unsolicited msg handler")
                raise