Listen for incoming single messages
507666
function listen(next) {

        listenSocket = dgram.createSocket({ type: 'udp4', reuseAddr: true });

        listenSocket.on('message', function(payload, rinfo) {
            var message = parseMessage(payload, rinfo);
            if (message) {
                if (message.id != id) {
                    if (message.status == "ONE") {
                        updateNodeList(message);
                    } else if (message.name != listenNameIdentifier && message.status == "NAMETAKEN") {
                        stop(function() {
                            //throw new Error('name already taken "' + name + '"');
                            self.emit("error", {cause: "Name already taken"});
                        });
                    }
                } else {
                    //self.emit('error', id + " already exists in network");
                    throw new Error(id + ' already exits in network');
                    stop();
                }
            }
        });

        listenSocket.bind(function(err) {
            var info = listenSocket.address();
            self.port = info.port;
            next(err);
        });

    }
271002
async def listen(self):
        ""
        if self.subscribed:
            return self.handle_message(await self.parse_response(block=True))
15210
def _message_received(self, message):
        """"""
        with self.lock:
            self._state.receive_message(message)
            for callable in chain(self._on_message_received, self._on_message):
                callable(message)
663243
def on_message(self, *args, accept_query=False, matcher=None, **kwargs):
        

        if accept_query:
            def new_matcher(msg: Message):
                ret = True
                if matcher:
                    ret = matcher(msg)
                    if ret is None or ret is False:
                        return ret
                if msg.recipient is not self and not isinstance(msg.sender, User):
                    return False
                return ret
        else:
            kwargs.setdefault("channel", self.name)
            new_matcher = matcher
        return self.client.on_message(*args, matcher=new_matcher, **kwargs)
564909
def _dry_message_received(self, msg):
        """"""
        for callback in self._dry_wet_callbacks:
            callback(LeakSensorState.DRY)
        self._update_subscribers(0x11)
347970
def listen(self):
        

        logger.info("Listening on port " + str(self.listener.listen_port))
        self.listener.listen()
650233
private function listen()
    {
        do {
            $data = fgets($this->socket, 512);
            if (!empty($data)) {
                $request   = $this->receive($data);
                $cmd       = strtolower($request->getCommand());

                if ($cmd === 'privmsg') {
                    $event_name = 'message.' . ($request->isPrivateMessage() ? 'private' : 'channel');
                } else {
                    $event_name = 'server.' . $cmd;
                }

                // Skip processing if the incoming message is from the bot
                if ($request->getSendingUser() === $this->config['nick']) {
                    continue;
                }

                $event = new Event($request);
                $this->dispatcher->dispatch($event_name, $event);
                $responses = $event->getResponses();

                if (!empty($responses)) {
                    $this->send($responses);
                }
            }
        } while (!feof($this->socket) && false === $this->askStop);
    }
357794
def _wet_message_received(self, msg):
        """"""
        for callback in self._dry_wet_callbacks:
            callback(LeakSensorState.WET)
        self._update_subscribers(0x13)
391055
def on_message(self, event):
        '''
        '''

        metadata = self._parse_metadata(event)
        message = Message(text=metadata['text'],
                          metadata=metadata).__dict__
        if message.get('text'):
            message['text'] = self.find_and_replace_userids(message['text'])
            message['text'] = self.find_and_replace_channel_refs(
                message['text']
            )
        return message
364466
def on_message(self, con, event):
        """"""
        msg_type = event.getType()
        nick = event.getFrom().getResource()
        from_jid = event.getFrom().getStripped()
        body = event.getBody()

        if msg_type == 'chat' and body is None:
            return

        logger.debug('msg_type[%s] from[%s] nick[%s] body[%s]' % (msg_type, from_jid, nick, body,))

        sender = filter(lambda m: m['JID'] == from_jid, self.params['MEMBERS'])

        should_process = msg_type in ['message', 'chat', None] and body is not None and len(sender) == 1
        if not should_process: return
        sender = sender[0]

        try:
            for p in self.command_patterns:
                reg, cmd = p
                m = reg.match(body)
                if m:
                    logger.info('pattern matched for bot command \'%s\'' % (cmd,))
                    function = getattr(self, str(cmd), None)
                    if function:
                        return function(sender, body, m)

            words = body.split(' ')
            cmd, args = words[0], words[1:]
            if cmd and cmd[0] == '/':
                cmd = cmd[1:]
                command_handler = getattr(self, 'do_'+cmd, None)
                if command_handler:
                    return command_handler(sender, body, args)

            broadcast_body = '[%s] %s' % (sender['NICK'], body,)
            return self.broadcast(broadcast_body, exclude=(sender,))
        except:
            logger.exception('Error handling message [%s] from [%s]' % (body, sender['JID']))
373621
def on_message(self, ws, reply, *args):
        
        log.debug("Received message: %s" % str(reply))
        data = {}
        try:
            data = json.loads(reply, strict=False)
        except ValueError:
            raise ValueError("API node returned invalid format. Expected JSON!")

        if data.get("method") == "notice":
            id = data["params"][0]

            if id >= len(self.__events__):
                log.critical("Received an id that is out of range\n\n" + str(data))
                return

            # This is a "general" object change notification
            if id == self.__events__.index("on_object"):
                # Let's see if a specific object has changed
                for notice in data["params"][1]:
                    try:
                        if "id" in notice:
                            self.process_notice(notice)
                        else:
                            for obj in notice:
                                if "id" in obj:
                                    self.process_notice(obj)
                    except Exception as e:
                        log.critical(
                            "Error in process_notice: {}\n\n{}".format(
                                str(e), traceback.format_exc
                            )
                        )
            else:
                try:
                    callbackname = self.__events__[id]
                    log.info("Patching through to call %s" % callbackname)
                    [getattr(self.events, callbackname)(x) for x in data["params"][1]]
                except Exception as e:
                    log.critical(
                        "Error in {}: {}\n\n{}".format(
                            callbackname, str(e), traceback.format_exc()
                        )
                    )
767973
def _notify_listeners(self, sender, message):
        
        uid = message['uid']
        msg_topic = message['topic']


        self._ack(sender, uid, 'fire')

        all_listeners = set()
        for lst_topic, listeners in self.__listeners.items():
            if fnmatch.fnmatch(msg_topic, lst_topic):
                all_listeners.update(listeners)

        self._ack(sender, uid, 'notice', 'ok' if all_listeners else 'none')

        try:
            results = []
            for listener in all_listeners:
                result = listener.handle_message(sender,
                                                 message['topic'],
                                                 message['content'])
                if result:
                    results.append(result)

            self._ack(sender, uid, 'send', json.dumps(results))
        except:
            self._ack(sender, uid, 'send', "Error")
140816
function onListening() {
    const addr = server.address();
    const bind = (typeof addr === 'string')
                ? 'pipe ' + addr
                : 'port ' + addr.port;
    debugServer('Listening on ' + bind);
  }
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)
1269708
def on_message_received(self, msg):
        
        if self.is_stopped:
            raise RuntimeError("reader has already been stopped")
        else:
            self.buffer.put(msg)
577977
def listen(self):
        ''''''
        try:
            self._pubsub.subscribe(self._channels)
            for message in self._pubsub.listen():
                if message['type'] == 'message':
                    yield message
        finally:
            self._channels = []
1362191
def listen_tta(self, target, timeout):
        """"""
        info = "{device} does not support listen as Type A Target"
        raise nfc.clf.UnsupportedTargetError(info.format(device=self))