Net/Notifier/WebSocket/Handshake.php
public function receive($data, $nonce, array $protocols = array())
    {
        $handshake = $this->parseHeaders($data);
        $headers   = $handshake['headers'];

        // get status code from status line
        $status_parts = explode(' ', $handshake['status']);
        if (count($status_parts) > 1) {
            $status = (integer)$status_parts[1];
        } else {
            $status = 400;
        }

        // get method from status line
        $method = $status_parts[0];

        if ($status == '101') {
            $response = $this->receiveServerHandshake(
                $headers,
                $nonce,
                $protocols
            );
        } elseif ($method === 'GET') {
            $response = $this->receiveClientHandshake($headers, $protocols);
        } else {
            $response = "HTTP/1.1 400 Bad Request\r\n\r\n";
        }

        return $response;
    }
public function receive($data, $nonce, array $protocols = array())
    {
        $handshake = $this->parseHeaders($data);
        $headers   = $handshake['headers'];

        // get status code from status line
        $status_parts = explode(' ', $handshake['status']);
        if (count($status_parts) > 1) {
            $status = (integer)$status_parts[1];
        } else {
            $status = 400;
        }

        // get method from status line
        $method = $status_parts[0];

        if ($status == '101') {
            $response = $this->receiveServerHandshake(
                $headers,
                $nonce,
                $protocols
            );
        } elseif ($method === 'GET') {
            $response = $this->receiveClientHandshake($headers, $protocols);
        } else {
            $response = "HTTP/1.1 400 Bad Request\r\n\r\n";
        }

        return $response;
    }
public function receive ( $ data , $ nonce , array $ protocols = array ( ) ) { $ handshake = $ this -> parseHeaders ( $ data ) ; $ headers = $ handshake [ 'headers' ] ; // get status code from status line $ status_parts = explode ( ' ' , $ handshake [ 'status' ] ) ; if ( count ( $ status_parts ) > 1 ) { $ status = ( integer ) $ status_parts [ 1 ] ; } else { $ status = 400 ; } // get method from status line $ method = $ status_parts [ 0 ] ; if ( $ status == '101' ) { $ response = $ this -> receiveServerHandshake ( $ headers , $ nonce , $ protocols ) ; } elseif ( $ method === 'GET' ) { $ response = $ this -> receiveClientHandshake ( $ headers , $ protocols ) ; } else { $ response = "HTTP/1.1 400 Bad Request\r\n\r\n" ; } return $ response ; }
Does the actual WebSocket handshake

See section 4.2.2 of
{@link http://datatracker.ietf.org/doc/rfc6455/ IETF RFC 6455} for
further details.

@param string $data      the handshake request/response data.
@param string $nonce     the nonce value used to validate this handshake.
Not set for receiving client handshake requests.
@param array  $protocols optional. A list of supported or requested
application-specific sub-protocols. If
specified, only handshake requests for the
specified protocols will succeed.

@return string|null the handshake response or null if there is no
response.

@throws Net_Notifier_WebSocket_HandshakeFailureException if the
handshake fails.

@todo Handle 4XX responses from server properly on client.
Does the actual WebSocket handshake