Handles WebSocket closes received by the client.

@param int    $op     The close code.
@param string $reason The reason the WebSocket closed.
349503
public function handleWsClose($op, $reason)
    {
        $this->connected = false;

        if (! is_null($this->heartbeatTimer)) {
            $this->heartbeatTimer->cancel();
            $this->heartbeatTimer = null;
        }

        if (! is_null($this->heartbeatAckTimer)) {
            $this->heartbeatAckTimer->cancel();
            $this->heartbeatAckTimer = null;
        }

        if ($this->closing) {
            return;
        }

        $this->logger->warning('websocket closed', ['op' => $op, 'reason' => $reason]);

        if ($op == Op::CLOSE_INVALID_TOKEN) {
            $this->emit('error', ['token is invalid', $this]);
            $this->logger->error('the token you provided is invalid');

            return;
        }

        ++$this->reconnectCount;
        $this->reconnecting = true;
        $this->logger->info('starting reconnect', ['reconnect_count' => $this->reconnectCount]);
        $this->connectWs();
    }
1053428
public function close($data = null, $raw = false)
    {
        if ($data !== null) {
            $this->send($data, $raw);
        }
        Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ);
        fclose($this->_socket);
        $this->connected = false;
        // Try to emit onClose callback.
        if ($this->onClose) {
            try {
                call_user_func($this->onClose, $this);
            } catch (\Exception $e) {
                Worker::log($e);
                exit(250);
            } catch (\Error $e) {
                Worker::log($e);
                exit(250);
            }
        }
        $this->onConnect = $this->onMessage = $this->onClose = null;
        return true;
    }
656945
@Override
    public synchronized void processClose(WebSocketChannel channel, int code, String reason) {
        nextHandler.processClose(channel, code, reason);        
    }
1214937
function close_tunnel(status) {

        // Ignore if already closed
        if (tunnel.state === Guacamole.Tunnel.State.CLOSED)
            return;

        // If connection closed abnormally, signal error.
        if (status.code !== Guacamole.Status.Code.SUCCESS && tunnel.onerror)
            tunnel.onerror(status);

        // Mark as closed
        tunnel.setState(Guacamole.Tunnel.State.CLOSED);

        socket.close();

    }
99972
def close(self, reason=None):
        
        with self._closing:
            if self._closed:
                return

            self._websocket.close()

            self._consumer.join()
            self._consumer = None

            self._websocket = None
            self._closed = True
            for cb in self._close_callbacks:
                cb(self, reason)
945759
public function processClose($event)
    {
        $response = new Response();
        $response->opcode = Request::OPCODE_CLOSE;
        return $event->sender->close($response);
    }
528165
@Override
    public void processClose(WebSocketChannel channel, int code, String reason) {
        LOG.entering(CLASS_NAME, "close");

        //2. check current readyState
        WebSocketCompositeChannel parent = (WebSocketCompositeChannel)channel;

        // When the connection timeout expires due to network loss, we first
        // invoke doClose() to inform the application immediately. Then, we
        // invoke processClose() to close the connection but it may take a
        // while to return. When doClose() is invoked, readyState is set to
        // CLOSED. However, we do want processClose() to be invoked all the
        // all the way down to close the connection. That's why we are no
        // longer throwing an exception here if readyState is CLOSED.
        
        if (!parent.closing) {
            parent.closing = true;
            parent.readyState = ReadyState.CLOSING;
            
            try {
                WebSocketSelectedChannel selectedChannel = parent.selectedChannel;
                selectedChannel.handler.processClose(selectedChannel, code, reason);                
            }
            catch (Exception e) {
                doClose(parent, false, CloseCommandMessage.CLOSE_ABNORMAL, e.getMessage());
            }
        }
    }
810846
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);
    }
168302
function close()
    {
        if(!$this->socket) {
            return;
        }

        $this->sendDisconnect();
        stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
        $this->socket = null;
    }
143018
static function close($socket,$event=null)
    {
        if($event)
        {
            event_del($event);
            event_free($event);
        }
        fclose($socket);
    }
122751
def on_close(self) -> None:
        """"""
        logger.info('WebSocket CLOSED')
        if self in connections:
            # Remove this connection from connection-list
            connections.remove(self)
        # close if auto_shutdown is enabled and there is no more connection
        if config.auto_shutdown and not is_connected():
            asyncio.ensure_future(self.terminate())
70504
@Handler(channels = NetworkChannel.class)
    public void onClosed(Closed event, TcpChannel netConnChannel) {
        netConnChannel.associated(WebAppMsgChannel.class).ifPresent(
            appChannel -> appChannel.handleClosed(event));
        pooled.remove(netConnChannel.remoteAddress(), netConnChannel);
    }
92566
public function close($code = 1000, $reason = '')
    {
        return $this->server->disconnect($this->id, $code, $reason);
    }
901691
def closed(self, code, reason=None):
        """"""
        if code != 1000:
            self._error = errors.SignalFlowException(code, reason)
            _logger.info('Lost WebSocket connection with %s (%s: %s).',
                         self, code, reason)
            for c in self._channels.values():
                c.offer(WebSocketComputationChannel.END_SENTINEL)
        self._channels.clear()
        with self._connection_cv:
            self._connected = False
            self._connection_cv.notify()
453358
function execute(Observer $ob) {
		/** @var OP $op */
		if (dfp_my($op = $ob['payment'])) {
			$op->getOrder()->setState(O::STATE_CLOSED)->setStatus(df_order_ds(O::STATE_CLOSED));
		}
	}
854064
function closeUserSock($user)
    {
        fclose($this->users[$user]['sock']);
        $this->users[$user]['sock'] = 0;
        return true;
    }
1281556
public static function onClose($connection)
    {
        $connection->handshakeStep               = null;
        $connection->websocketCurrentFrameLength = 0;
        $connection->tmpWebsocketData            = '';
        $connection->websocketDataBuffer         = '';
        if (!empty($connection->websocketPingTimer)) {
            Timer::del($connection->websocketPingTimer);
            $connection->websocketPingTimer = null;
        }
    }