Exemplo n.º 1
0
 private function acceptSocket()
 {
     try {
         $client = stream_socket_accept($this->master);
         if ($client === false) {
             WebSocketFunctions::say('socket_accept() failed');
         }
         $this->sockets->attach(new WebSocketSocket($this, $client));
         $this->debug("Socket accepted");
     } catch (Exception $e) {
         $this->say($e);
     }
 }
 public function sendHandshakeResponse()
 {
     // Check for newer handshake
     $challenge = isset($this->_headers['Sec-Websocket-Key']) ? $this->_headers['Sec-Websocket-Key'] : null;
     // Build response
     $response = "HTTP/1.1 101 WebSocket Protocol Handshake\r\n" . "Upgrade: WebSocket\r\n" . "Connection: Upgrade\r\n";
     // Build HYBI response
     $response .= "Sec-WebSocket-Accept: " . WebSocketFunctions::calcHybiResponse($challenge) . "\r\n\r\n";
     $this->_socket->write($response);
     WebSocketFunctions::say("HYBI Response SENT!");
 }