コード例 #1
0
 /**
  * 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');
 }
コード例 #2
0
 /**
  * Accepts a new connection.
  *
  * @param resource $listenerStream The socket created by stream_socket_server
  */
 private function newConnection($listenerStream)
 {
     $stream = stream_socket_accept($listenerStream);
     // The first bit of data from the client should be a HTTP request.
     $req = HttpRequest::FromStream($stream, [$this, 'gotHeaders']);
     // Send the stream to the HTTP request handler.
     $this->streams->addStream($stream, null, $req);
 }