protected function _makeWebsocketRequest($type, $params, $once = false)
    {
        switch (strtoupper($type)) {
            default:
            case 'DEPTH':
                $url = ConnectionDetails::WEBSOCKET_URL . strtolower($params['symbol']) . '@depth';
                break;
            case 'KLINE':
                $url = ConnectionDetails::WEBSOCKET_URL . strtolower($params['symbol']) . '@kline_' . $params['interval'];
                break;
            case 'TRADES':
                $url = ConnectionDetails::WEBSOCKET_URL . strtolower($params['symbol']) . '@aggTrade';
                break;
            case 'USER':
                $url = ConnectionDetails::WEBSOCKET_URL . strtolower($params['symbol']);
                break;
        }

        \Ratchet\Client\connect($url)->then(function (WebSocket $conn) use ($once) {
            $conn->on('message', function (MessageInterface $msg) use ($conn, $once) {
                echo $msg . "\n";
                if ($once) $conn->close();
            });

            $conn->on('close', function ($code = null, $reason = null) {
                echo 'Connection closed (' . $code . ' - ' . $reason . ')';
            });

            $conn->on('error', function () {
                throw new LarislackersException('[ERROR|Websocket] Could not establish a connection.');
            });
        });
    }
protected function _makeWebsocketRequest($type, $params, $once = false)
    {
        switch (strtoupper($type)) {
            default:
            case 'DEPTH':
                $url = ConnectionDetails::WEBSOCKET_URL . strtolower($params['symbol']) . '@depth';
                break;
            case 'KLINE':
                $url = ConnectionDetails::WEBSOCKET_URL . strtolower($params['symbol']) . '@kline_' . $params['interval'];
                break;
            case 'TRADES':
                $url = ConnectionDetails::WEBSOCKET_URL . strtolower($params['symbol']) . '@aggTrade';
                break;
            case 'USER':
                $url = ConnectionDetails::WEBSOCKET_URL . strtolower($params['symbol']);
                break;
        }

        \Ratchet\Client\connect($url)->then(function (WebSocket $conn) use ($once) {
            $conn->on('message', function (MessageInterface $msg) use ($conn, $once) {
                echo $msg . "\n";
                if ($once) $conn->close();
            });

            $conn->on('close', function ($code = null, $reason = null) {
                echo 'Connection closed (' . $code . ' - ' . $reason . ')';
            });

            $conn->on('error', function () {
                throw new LarislackersException('[ERROR|Websocket] Could not establish a connection.');
            });
        });
    }
protected function _makeWebsocketRequest ( $ type , $ params , $ once = false ) { switch ( strtoupper ( $ type ) ) { default : case 'DEPTH' : $ url = ConnectionDetails :: WEBSOCKET_URL . strtolower ( $ params [ 'symbol' ] ) . '@depth' ; break ; case 'KLINE' : $ url = ConnectionDetails :: WEBSOCKET_URL . strtolower ( $ params [ 'symbol' ] ) . '@kline_' . $ params [ 'interval' ] ; break ; case 'TRADES' : $ url = ConnectionDetails :: WEBSOCKET_URL . strtolower ( $ params [ 'symbol' ] ) . '@aggTrade' ; break ; case 'USER' : $ url = ConnectionDetails :: WEBSOCKET_URL . strtolower ( $ params [ 'symbol' ] ) ; break ; } \ Ratchet \ Client \ connect ( $ url ) -> then ( function ( WebSocket $ conn ) use ( $ once ) { $ conn -> on ( 'message' , function ( MessageInterface $ msg ) use ( $ conn , $ once ) { echo $ msg . "\n" ; if ( $ once ) $ conn -> close ( ) ; } ) ; $ conn -> on ( 'close' , function ( $ code = null , $ reason = null ) { echo 'Connection closed (' . $ code . ' - ' . $ reason . ')' ; } ) ; $ conn -> on ( 'error' , function ( ) { throw new LarislackersException ( '[ERROR|Websocket] Could not establish a connection.' ) ; } ) ; } ) ; }
Opens a websocket connection and transmits received messages until closed.

@param string $type   The websocket method.
@param array  $params The parameters to send.
@param bool   $once   If true, it will close the connection after the first successful message.

@return void
@throws LarislackersException
Opens a websocket connection and transmits received messages until closed .