public function onMessage(Server $server, Frame $frame)
    {
        $fd = $frame->fd;

        // init fd and coId mapping
        WebSocketContext::setFdToCoId($fd);

        App::trigger(WsEvent::ON_MESSAGE, null, $server, $frame);

        $this->log("received message: {$frame->data} from fd #{$fd}, co ID #" . Coroutine::tid(), [], 'debug');

        /** @see Dispatcher::message() */
        \bean('wsDispatcher')->message($server, $frame);

        // delete coId to fd mapping
        WebSocketContext::delFdByCoId();
        RequestContext::destroy();
    }
public function onMessage(Server $server, Frame $frame)
    {
        $fd = $frame->fd;

        // init fd and coId mapping
        WebSocketContext::setFdToCoId($fd);

        App::trigger(WsEvent::ON_MESSAGE, null, $server, $frame);

        $this->log("received message: {$frame->data} from fd #{$fd}, co ID #" . Coroutine::tid(), [], 'debug');

        /** @see Dispatcher::message() */
        \bean('wsDispatcher')->message($server, $frame);

        // delete coId to fd mapping
        WebSocketContext::delFdByCoId();
        RequestContext::destroy();
    }
public function onMessage ( Server $ server , Frame $ frame ) { $ fd = $ frame -> fd ; // init fd and coId mapping WebSocketContext :: setFdToCoId ( $ fd ) ; App :: trigger ( WsEvent :: ON_MESSAGE , null , $ server , $ frame ) ; $ this -> log ( "received message: {$frame->data} from fd #{$fd}, co ID #" . Coroutine :: tid ( ) , [ ] , 'debug' ) ; /** @see Dispatcher::message() */ \ bean ( 'wsDispatcher' ) -> message ( $ server , $ frame ) ; // delete coId to fd mapping WebSocketContext :: delFdByCoId ( ) ; RequestContext :: destroy ( ) ; }
When you receive the message
@param  Server $server
@param  Frame $frame
@throws \Swoft\WebSocket\Server\Exception\WsRouteException
@throws \Swoft\WebSocket\Server\Exception\WsMessageException
@throws \InvalidArgumentException
When you receive the message