/** * Tests if a stream can't be accessed if it's removed. */ public function testRemoveStream() { $reader = new SocketReader(); $stream = $this->createStream(); $id = $reader->addStream($stream, "stream1"); $reader->removeStream($id); $foundId = $reader->getId($stream) !== FALSE; $foundStream = $reader->getStream($id); self::assertFalse($foundId, 'Stream not found'); self::assertNull($foundStream, 'ID not found'); }
/** * Called when the HTTP request headers have been received. * * @param HttpRequest $req * @param $success */ public function gotHeaders(HttpRequest $req, $success) { $stream = $req->getStream(); $streamId = $this->streams->getId($stream); // Remove the stream from the list, because the HttpRequest is listening to it. $this->streams->removeStream($streamId); if ($success) { $success = $this->performHandshake($req); } if (!$success) { fclose($stream); return; } // Send the stream events to this class. $streamId = $this->streams->addStream($stream, $streamId, $this); $connection = new ClientConnection($stream, $streamId); $connection->addEventListener($this); $this->connections[$streamId] = $connection; $e = $this->createEvent(WebSocketServer::EVENT_CONNECTED); $e->connection = $connection; $this->notifyEventListeners($e); }