"onMessage" listener.

@param Server $server
@param Frame  $frame
512105
public function onMessage($server, $frame)
    {
        // execute parser strategies and skip non-message packet
        if ($this->payloadParser->execute($server, $frame)) {
            return;
        }

        /** @var Websocket $websocket */
        $websocket = $this->app->make(Websocket::class);
        /** @var Sandbox $sandbox */
        $sandbox = $this->app->make(Sandbox::class);

        try {
            // decode raw message via parser
            $payload = $this->payloadParser->decode($frame);

            $websocket->reset(true)->setSender($frame->fd);

            // enable sandbox
            $sandbox->init();

            // dispatch message to registered event callback
            ['event' => $event, 'data' => $data] = $payload;
            $websocket->eventExists($event)
                ? $websocket->call($event, $data)
                : $this->websocketHandler->onMessage($frame);
        } catch (Throwable $e) {
            $this->logServerError($e);
        } finally {
            // disable and recycle sandbox resource
            $sandbox->clear();
        }
    }
1281494
public void onMessage(Mtp2Buffer rxFrame, Mtp2 mtp2) {
        // | ----------------------- TO L4 --------------------------- |
        // | --------------------- SIF ------------------------ |
        // FSN BSN LEN SIO DPC/OPC,SLS HEADING LEN
        // b1 b0 0e 01 01 80 00 00 21 70 01 02 03 04 05 06 0f CRC CRC
        int sio = rxFrame.frame[3] & 0xFF;
        int subserviceIndicator = (sio >> 4) & 0x0F;
        int serviceIndicator = sio & 0x0F;
        int ni = (subserviceIndicator & 0x0C); // local NI(network Indicator) form msg., 0x0C, since we store it as shifted
                                               // value.
        // int dpc = (sif[0] & 0xff | ((sif[1] & 0x3f) << 8));
        // int opc = ((sif[1] & 0xC0) >> 6) | ((sif[2] & 0xff) << 2) | ((sif[3]
        // & 0x0f) << 10);
        // int sls = (sif[3] & 0xf0) >>> 4;
        int dpc = dpc(rxFrame.frame, 4); // 1 - cause sif contains sio, even though its also passed as arg.
        int opc = opc(rxFrame.frame, 4);
        int sls = sls(rxFrame.frame, 4);

        // check SSI, Q.704 Figure 25, seems like if its bad, we discard.
        if (this.ni != ni) {
            if (logger.isEnabledFor(Level.ERROR)) {
                logger.error(String.format("(%s) Received MSSU with bad SSI, discarding! ni:" + ni + " thisni:" + this.ni
                        + " [si=" + serviceIndicator + ",ssi=" + subserviceIndicator + ", dpc=" + dpc + ", opc=" + opc
                        + ", sls=" + sls + "] data: ", mtp2.getName())
                        + Arrays.toString(rxFrame.frame));
            }
            return;
        }

        switch (serviceIndicator) {
            case LINK_MANAGEMENT:
                int h0 = rxFrame.frame[8] & 0x0f;
                int h1 = (rxFrame.frame[8] & 0xf0) >>> 4;

                if (logger.isDebugEnabled()) {
                    logger.debug(String.format("(%s) Signalling network management", mtp2.getName()));
                }

                if (h0 == 0) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Changeover management", mtp2.getName()));
                    }
                } else if (h0 == 7 && h1 == 1) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) TRA received", mtp2.getName()));
                    }
                }
                // FIX ME
                break;
            case LINK_TESTING:
                h0 = rxFrame.frame[8] & 0x0f;
                h1 = (rxFrame.frame[8] & 0xf0) >>> 4;

                int len = (rxFrame.frame[9] & 0xf0) >>> 4;
                if (h0 == 1 && h1 == 1) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Received SLTM", mtp2.getName()));
                    }
                    // receive SLTM from remote end
                    // create response

                    // change order of opc/dpc in SLTA !
                    writeRoutingLabel(this.localFrame, sio, this.ni, sls, opc, dpc);
                    // slta[0] = (byte) sio;
                    this.localFrame[5] = 0x021;
                    // +1 cause we copy LEN byte also.
                    System.arraycopy(rxFrame.frame, 9, this.localFrame, 6, len + 1);

                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Responding with SLTA", mtp2.getName()));
                    }
                    mtp2.send(this.localFrame, len + 9);
                } else if (h0 == 1 && h1 == 2) {
                    // receive SLTA from remote end
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Received SLTA", mtp2.getName()));
                    }

                    // checking pattern
                    if (checkPattern(rxFrame, len, SLTM_PATTERN)) {
                        // test message is acknowledged
                        mtp2.sltmTest.ack();

                        // notify top layer that link is up
                        if (!l4IsUp) {
                            l4IsUp = true;
                            linkUp(mtp2);
                        }
                    } else {
                        if (logger.isEnabledFor(Level.WARN)) {
                            logger.warn("SLTA pattern does not match: \n" + Arrays.toString(rxFrame.frame) + "\n"
                                    + Arrays.toString(SLTM_PATTERN));
                        }
                    }
                } else {
                    if (logger.isEnabledFor(Level.WARN)) {
                        logger.warn(String.format("(%s) Unexpected message type", mtp2.getName()));
                    }
                }
                break;
            case _SI_SERVICE_SCCP:
                if (logger.isDebugEnabled()) {
                    logger.debug("Received SCCP MSU");
                }

                if (mtp3Listener != null) {

                    // | ----------------------- TO L4 --------------------------- |
                    // | --------------------- SIF ------------------------ |
                    // FSN BSN LEN SIO DPC/OPC,SLS HEADING LEN
                    // b1 b0 0e 01 01 80 00 00 21 70 01 02 03 04 05 06 0f CRC CRC
                    byte[] messageBuffer = new byte[rxFrame.len - 5]; // -5 = FSN(1) + BSN(1) + LEN(1) +2xCRC(1)
                    System.arraycopy(rxFrame.frame, 3, messageBuffer, 0, rxFrame.len - 5);
                    // messageBuffer[0] = (byte) sio;
                    try {
                        mtp3Listener.receive(messageBuffer);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                break;
            case _SI_SERVICE_ISUP:
                if (logger.isDebugEnabled()) {
                    logger.debug("Received ISUP MSU");

                }
                if (mtp3Listener != null) {
                    byte[] messageBuffer = new byte[rxFrame.len - 5];
                    System.arraycopy(rxFrame.frame, 3, messageBuffer, 0, rxFrame.len - 5);
                    // messageBuffer[0] = (byte) sio;
                    try {
                        mtp3Listener.receive(messageBuffer);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                break;
            default:
                if (logger.isEnabledFor(Level.WARN)) {
                    logger.warn("Received MSU for UNKNOWN SERVICE!!!!!!!!!!!: " + Utils.dump(rxFrame.frame, rxFrame.len, false));
                }
                break;
        }
    }
212267
function onmessage(packet) {
    if (arguments.length === 2) packet = arguments[1];
    packet = parse(packet);

    if (allowed(packet)) emit(packet);
  }
1064768
public function receiveFrame(Frame $frame)
    {
        if ('ERROR' === $frame->command) {
            throw new ServerErrorException($frame);
        }

        if ($this->state->isConnecting()) {
            if ('CONNECTED' !== $frame->command) {
                throw new InvalidFrameException(sprintf("Received frame with command '%s', expected 'CONNECTED'.", $frame->command));
            }

            $this->state->doneConnecting(
                $frame->getHeader('session'),
                $frame->getHeader('server')
            );

            return new ConnectionEstablishedCommand();
        }

        if ('CONNECTED' === $frame->command) {
            throw new InvalidFrameException(sprintf("Received 'CONNECTED' frame outside a connecting window."));
        }

        if ($this->state->isDisconnecting()) {
            if ('RECEIPT' === $frame->command && $this->state->isDisconnectionReceipt($frame->getHeader('receipt-id'))) {
                $this->state->doneDisconnecting();

                return new CloseCommand();
            }
        }

        return new NullCommand();
    }
910778
public function onPacket(SwServer $server, string $data, array $clientInfo)
    {
        // {{ log
        $this->get('logger')->info('接收数据', [
            'type' => 'UDP',
            'client' => $clientInfo,
            'data' => $data
        ]);
        // }}

        $this->callProtocolMethod('onPacket', $server, $data, $clientInfo);
    }
569567
protected void fireFrameReceived(final CEMI frame)
	{
		final FrameEvent fe = new FrameEvent(this, frame);
		listeners.fire(l -> l.frameReceived(fe));
	}
47030
public function onReceive(Server $server, int $fd, int $fromId, string $data): void
    {
        $data = \trim($data);
        $this->log("Receive data [$data] from client [FD:$fd]. fromId: $fromId");

        if ($this->handler) {
            $this->handler->onReceive($server, $fd, $fromId, $data);
        } else {
            $server->send($fd, "I have been received your message.\n");
        }

        // 群发收到的消息
        // $this->reloadWorker->write($data);

        // 投递异步任务
        // example 1 add task
        // $taskId = $server->task($data);
        // 需swoole-1.8.6或更高版本
        // $server->task("task data", -1, function (Server $server, $task_id, $data) {
        //     echo "Task Callback: ";
        //     var_dump($task_id, $data);
        // });

        // example 3 use sendMessage()
        // if (trim($data) == 'task') {
        //     $taskId = $server->task("async task coming");
        // } else {
        //     $worker_id = 1 - $server->worker_id;
        //     // can trigger onPipeMessage event.
        //     $server->sendMessage("hello task process", $worker_id);
        // }
    }
664920
public function receivedFrame(Frame $frame)
    {
        foreach ($this->observers as $item) {
            $item->receivedFrame($frame);
        }
    }
504085
public function onStart(Server $server)
    {
        \file_put_contents($this->serverSetting['pfile'], $server->master_pid . ',' . $server->manager_pid);

        ProcessHelper::setProcessTitle($this->serverSetting['pname'] . ' master process (' . $this->scriptFile . ')');

        $this->fireServerEvent(SwooleEvent::ON_START, [$server]);
    }
207035
public function onManagerStop(Server $server): void
    {
        $this->fire(ServerEvent::MANAGER_STOPPED, $server);
        $this->log("The manager process stopped. (PID {$server->manager_pid})");

        ServerUtil::removePidFile($this->pidFile);
    }
106704
function onServerMessage(data)
    {
        if(data.ev)
        {
            scope.dispatchEvent("onServerMessage",data);
            scope.dispatchEvent(data.ev,data);
        }
    }
1334301
protected function _check_callbacks($event, $frame) {
    if (!isset($this->_callbacks)) {
      $this->_callbacks = $this->_dompdf->get_callbacks();
    }
    
    if (is_array($this->_callbacks) && isset($this->_callbacks[$event])) {
      $info = array(0 => $this->_canvas, "canvas" => $this->_canvas,
                    1 => $frame, "frame" => $frame);
      $fs = $this->_callbacks[$event];
      foreach ($fs as $f) {
        if (is_callable($f)) {
          if (is_array($f)) {
            $f[0]->$f[1]($info);
          } else {
            $f($info);
          }
        }
      }
    }
  }
482778
public void processError(String msg) {
        synchronized (frameListeners) {
            Iterator<FrameListener> it = frameListeners.iterator();
            while (it.hasNext()) {
                FrameListener listener = it.next();
                listener.processError(msg);
            }
        }
    }
4905
public function pushMessage($server, array $data)
    {
        $pusher = Pusher::make($data, $server);
        $pusher->push($this->payloadParser->encode(
            $pusher->getEvent(),
            $pusher->getMessage()
        ));
    }
1135538
def notify(self, frame_type, headers=None, body=None):
        
        if frame_type == 'receipt':
            # logic for wait-on-receipt notification
            receipt = headers['receipt-id']
            receipt_value = self.__receipts.get(receipt)
            with self.__send_wait_condition:
                self.set_receipt(receipt, None)
                self.__send_wait_condition.notify()

            if receipt_value == CMD_DISCONNECT:
                self.set_connected(False)
                # received a stomp 1.1+ disconnect receipt
                if receipt == self.__disconnect_receipt:
                    self.disconnect_socket()
                self.__disconnect_receipt = None

        elif frame_type == 'connected':
            self.set_connected(True)

        elif frame_type == 'disconnected':
            self.set_connected(False)

        with self.__listeners_change_condition:
            listeners = sorted(self.listeners.items())

        for (_, listener) in listeners:
            if not listener:
                continue

            notify_func = getattr(listener, 'on_%s' % frame_type, None)
            if not notify_func:
                log.debug("listener %s has no method on_%s", listener, frame_type)
                continue
            if frame_type in ('heartbeat', 'disconnected'):
                notify_func()
                continue
            if frame_type == 'connecting':
                notify_func(self.current_host_and_port)
                continue

            if frame_type == 'error' and not self.connected:
                with self.__connect_wait_condition:
                    self.connection_error = True
                    self.__connect_wait_condition.notify()

            rtn = notify_func(headers, body)
            if rtn:
                (headers, body) = rtn
        return (headers, body)
452527
public function onSwooleWSMessage($server, $frame)
    {
        $this->onSwooleWSAllMessage($server, $frame->fd, $frame->data);
    }
15662
public function message(Server $server, Frame $frame)
    {
        $fd = $frame->fd;

        try {
            if (!$path = WebSocketContext::getMeta('path', $fd)) {
                throw new ContextLostException("The connection info has lost of the fd#$fd, on message");
            }

            $className = $this->getHandler($path)[0];

            /** @var HandlerInterface $handler */
            $handler = \bean($className);
            $handler->onMessage($server, $frame);
        } catch (\Throwable $e) {
            /** @see \Swoft\Event\EventManager::hasListenerQueue() */
            if (App::hasBean('eventManager') && \bean('eventManager')->hasListenerQueue(WsEvent::ON_ERROR)) {
                App::trigger(WsEvent::ON_ERROR, $frame, $e);
            } else {
                App::error($e->getMessage(), ['fd' => $fd, 'data' => $frame->data]);
                // close connection
                $server->close($fd);
            }
        }
    }