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();
        }
    }
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();
        }
    }
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 ( ) ; } }
"onMessage" listener.

@param Server $server
@param Frame  $frame
onMessage listener .