public function onClose(\Swoole\WebSocket\Server $server, int $fd)
    {
        // echo "[websocket][onclose]client fd{$fd} closed\n";

        if ( empty(self::$websocketFrameContext[$fd]) ) {
            if ( getenv('STDOUT_LOG') ) {
                echo date('Y-m-d H:i:s') . " |\033[31m [ERROR][onClose] fd{$fd} WebSocket has been stoped...\033[0m \n";
            }
            return;
        }

        // Save websocket connection Context
        $context = self::$websocketFrameContext[$fd];

        // Restore global data
        $_POST   = $_SERVER = [];
        $_GET    = $_REQUEST = $context['get'];
        $_COOKIE = $context['cookie'];
        $controller_class = $context['controller_class'];

        // Clear websocket cache
        unset(self::$websocketFrameContext[$fd]);

        call_user_func([new $controller_class(), 'onClose'], $server, $fd);
    }
public function onClose(\Swoole\WebSocket\Server $server, int $fd)
    {
        // echo "[websocket][onclose]client fd{$fd} closed\n";

        if ( empty(self::$websocketFrameContext[$fd]) ) {
            if ( getenv('STDOUT_LOG') ) {
                echo date('Y-m-d H:i:s') . " |\033[31m [ERROR][onClose] fd{$fd} WebSocket has been stoped...\033[0m \n";
            }
            return;
        }

        // Save websocket connection Context
        $context = self::$websocketFrameContext[$fd];

        // Restore global data
        $_POST   = $_SERVER = [];
        $_GET    = $_REQUEST = $context['get'];
        $_COOKIE = $context['cookie'];
        $controller_class = $context['controller_class'];

        // Clear websocket cache
        unset(self::$websocketFrameContext[$fd]);

        call_user_func([new $controller_class(), 'onClose'], $server, $fd);
    }
public function onClose ( \ Swoole \ WebSocket \ Server $ server , int $ fd ) { // echo "[websocket][onclose]client fd{$fd} closed\n"; if ( empty ( self :: $ websocketFrameContext [ $ fd ] ) ) { if ( getenv ( 'STDOUT_LOG' ) ) { echo date ( 'Y-m-d H:i:s' ) . " |\033[31m [ERROR][onClose] fd{$fd} WebSocket has been stoped...\033[0m \n" ; } return ; } // Save websocket connection Context $ context = self :: $ websocketFrameContext [ $ fd ] ; // Restore global data $ _POST = $ _SERVER = [ ] ; $ _GET = $ _REQUEST = $ context [ 'get' ] ; $ _COOKIE = $ context [ 'cookie' ] ; $ controller_class = $ context [ 'controller_class' ] ; // Clear websocket cache unset ( self :: $ websocketFrameContext [ $ fd ] ) ; call_user_func ( [ new $ controller_class ( ) , 'onClose' ] , $ server , $ fd ) ; }
WebSocket on close

@param Swoole\WebSocket\Server $server
@param int $fd
@return void
WebSocket on close