Пример #1
0
 protected function clientTask(SocketServer $server, callable $callback) : \Generator
 {
     $factory = $server->createSocketFactory();
     if ($this->encrypted) {
         $factory->setCertificateAuthority(AsyncTestCase::getKoolKodeCertAuthorityFile());
     }
     $socket = (yield $factory->createSocketStream(2, $this->encrypted));
     try {
         $result = $callback($this->raw ? $socket->getSocket() : $socket);
         if ($result instanceof \Generator) {
             yield from $result;
         }
     } finally {
         $socket->close();
     }
 }
Пример #2
0
 /**
  * Setup HTTP client / server.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->httpServer = new HttpTestEndpoint($this->getDrivers(), 'localhost:1337', $this->isEncrypted());
     $this->httpClient = new HttpTestClient($this->getConnectors(), $this->httpServer);
 }