examples/tcp_proxy_example.php
protected function requestClose(WebSocketTransportInterface $user, $message)
    {
        $stream = $this->getStream($user, $message->connection);

        if($stream){
            $this->logger->notice(sprintf("User %s closes connection %s", $user->getId(), $message->connection));
            $stream->close();
            $this->removeStream($user, $message->connection);

            $user->sendString(json_encode(array(
                'event' => 'close',
                'connection' => $message->connection,
                'tag' => property_exists($message, 'tag') ? $message->tag : null
            )));
        } else {
            $user->sendString(json_encode(array(
                'event' => 'error',
                'tag' => property_exists($message, 'tag') ? $message->tag : null,
                'message' => 'Connection was already closed'
            )));
        }
    }
protected function requestClose(WebSocketTransportInterface $user, $message)
    {
        $stream = $this->getStream($user, $message->connection);

        if($stream){
            $this->logger->notice(sprintf("User %s closes connection %s", $user->getId(), $message->connection));
            $stream->close();
            $this->removeStream($user, $message->connection);

            $user->sendString(json_encode(array(
                'event' => 'close',
                'connection' => $message->connection,
                'tag' => property_exists($message, 'tag') ? $message->tag : null
            )));
        } else {
            $user->sendString(json_encode(array(
                'event' => 'error',
                'tag' => property_exists($message, 'tag') ? $message->tag : null,
                'message' => 'Connection was already closed'
            )));
        }
    }
protected function requestClose ( WebSocketTransportInterface $ user , $ message ) { $ stream = $ this -> getStream ( $ user , $ message -> connection ) ; if ( $ stream ) { $ this -> logger -> notice ( sprintf ( "User %s closes connection %s" , $ user -> getId ( ) , $ message -> connection ) ) ; $ stream -> close ( ) ; $ this -> removeStream ( $ user , $ message -> connection ) ; $ user -> sendString ( json_encode ( array ( 'event' => 'close' , 'connection' => $ message -> connection , 'tag' => property_exists ( $ message , 'tag' ) ? $ message -> tag : null ) ) ) ; } else { $ user -> sendString ( json_encode ( array ( 'event' => 'error' , 'tag' => property_exists ( $ message , 'tag' ) ? $ message -> tag : null , 'message' => 'Connection was already closed' ) ) ) ; } }
Close the stream specified by the user

@param WebSocketTransportInterface $user
@param $message
Close the stream specified by the user