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);
            }
        }
    }
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);
            }
        }
    }
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 ) ; } } }
dispatch ws message
@param Server $server
@param Frame $frame
@throws \InvalidArgumentException
@throws \Swoft\WebSocket\Server\Exception\WsRouteException
@throws \Swoft\WebSocket\Server\Exception\ContextLostException
dispatch ws message