Clue\React\Buzz\Io\Sender::createFromLoopConnectors PHP Méthode

createFromLoopConnectors() public static méthode

create sender attached to given event loop using the given connectors
public static createFromLoopConnectors ( React\EventLoop\LoopInterface $loop, React\SocketClient\ConnectorInterface $connector, React\SocketClient\ConnectorInterface $secureConnector = null ) : self
$loop React\EventLoop\LoopInterface
$connector React\SocketClient\ConnectorInterface default connector to use to establish TCP/IP connections
$secureConnector React\SocketClient\ConnectorInterface secure connector to use to establish TLS/SSL connections (optional, composed from given default connector)
Résultat self
    public static function createFromLoopConnectors(LoopInterface $loop, ConnectorInterface $connector, ConnectorInterface $secureConnector = null)
    {
        if ($secureConnector === null) {
            $secureConnector = new SecureConnector($connector, $loop);
        }
        // create HttpClient for React 0.4/0.3 (code coverage will be achieved by testing both versions)
        // @codeCoverageIgnoreStart
        $ref = new \ReflectionClass('React\\HttpClient\\Client');
        if ($ref->getConstructor()->getNumberOfRequiredParameters() == 2) {
            // react/http-client:0.4 removed the $loop parameter
            $http = new HttpClient($connector, $secureConnector);
        } else {
            $http = new HttpClient($loop, $connector, $secureConnector);
        }
        // @codeCoverageIgnoreEnd
        return new self($http);
    }

Usage Example

Exemple #1
0
 public function testSenderRejection()
 {
     $connector = $this->getMock('React\\SocketClient\\ConnectorInterface');
     $connector->expects($this->once())->method('create')->willReturn(Promise\reject(new RuntimeException('Rejected')));
     $sender = Sender::createFromLoopConnectors($this->loop, $connector);
     $request = new Request('GET', 'http://www.google.com/');
     $promise = $sender->send($request, $this->getMock('Clue\\React\\Buzz\\Message\\MessageFactory'));
     $this->setExpectedException('RuntimeException');
     Block\await($promise, $this->loop);
 }
All Usage Examples Of Clue\React\Buzz\Io\Sender::createFromLoopConnectors