Permalink
Browse files

[SocketClient] Rename Connector::createTcp to Connector::create

  • Loading branch information...
1 parent 0f05817 commit f2bd0d690bff2d2961d84f5bb6201d1e996d188c @igorw igorw committed Apr 14, 2013
View
@@ -22,12 +22,12 @@ HttpClient
----------
* `HttpClient\*ConnectionManager` has been moved to `SocketClient\*Connector`,
- and the `getConnection` method has been renamed to `createTcp`.
+ and the `getConnection` method has been renamed to `create`.
Before:
$connectionManager->getConnection($host, $port);
After:
- $connector->createTcp($host, $port);
+ $connector->create($host, $port);
@@ -218,7 +218,7 @@ protected function connect()
$port = $this->requestData->getPort();
return $this->connector
- ->createTcp($host, $port);
+ ->create($host, $port);
}
public function setResponseFactory($factory)
@@ -19,7 +19,7 @@ public function __construct(LoopInterface $loop, Resolver $resolver)
$this->resolver = $resolver;
}
- public function createTcp($host, $port)
+ public function create($host, $port)
{
$that = $this;
@@ -4,5 +4,5 @@
interface ConnectorInterface
{
- public function createTcp($host, $port);
+ public function create($host, $port);
}
@@ -34,13 +34,13 @@ $dns = $dnsResolverFactory->createCached('8.8.8.8', $loop);
### Async TCP/IP connections
The `React\SocketClient\Connector` provides a single promise-based
-`createTcp($host, $ip)` method which resolves as soon as the connection
+`create($host, $ip)` method which resolves as soon as the connection
succeeds or fails.
```php
$connector = new React\SocketClient\Connector($loop, $dns);
-$connector->createTcp('www.google.com', 80)->then(function (React\Stream\Stream $stream) {
+$connector->create('www.google.com', 80)->then(function (React\Stream\Stream $stream) {
$stream->write('...');
$stream->close();
});
@@ -50,13 +50,13 @@ $connector->createTcp('www.google.com', 80)->then(function (React\Stream\Stream
The `SecureConnector` class decorates a given `Connector` instance by enabling
SSL/TLS encryption as soon as the raw TCP/IP connection succeeds. It provides
-the same promise- based `createTcp($host, $ip)` method which resolves with
+the same promise- based `create($host, $ip)` method which resolves with
a `Stream` instance that can be used just like any non-encrypted stream.
```php
$secureConnector = new React\SocketClient\SecureConnector($connector, $loop);
-$secureConnector->createTcp('www.google.com', 443)->then(function (React\Stream\Stream $stream) {
+$secureConnector->create('www.google.com', 443)->then(function (React\Stream\Stream $stream) {
$stream->write("GET / HTTP/1.0\r\nHost: www.google.com\r\n\r\n");
...
});
@@ -19,10 +19,10 @@ public function __construct(ConnectorInterface $connector, LoopInterface $loop)
$this->streamEncryption = new StreamEncryption($loop);
}
- public function createTcp($host, $port)
+ public function create($host, $port)
{
$streamEncryption = $this->streamEncryption;
- return $this->connector->createTcp($host, $port)->then(function (Stream $stream) use ($streamEncryption) {
+ return $this->connector->create($host, $port)->then(function (Stream $stream) use ($streamEncryption) {
// (unencrypted) connection succeeded => try to enable encryption
return $streamEncryption->enable($stream)->then(null, function ($error) use ($stream) {
// establishing encryption failed => close invalid connection and return error
@@ -391,7 +391,7 @@ private function successfulConnectionMock()
{
$this->connector
->expects($this->once())
- ->method('createTcp')
+ ->method('create')
->with('www.example.com', 80)
->will($this->returnValue(new FulfilledPromise($this->stream)));
}
@@ -400,7 +400,7 @@ private function rejectedConnectionMock()
{
$this->connector
->expects($this->once())
- ->method('createTcp')
+ ->method('create')
->with('www.example.com', 80)
->will($this->returnValue(new RejectedPromise(new \RuntimeException())));
}
@@ -17,7 +17,7 @@ public function connectionToEmptyPortShouldFail()
$dns = $this->createResolverMock();
$connector = new Connector($loop, $dns);
- $connector->createTcp('127.0.0.1', 9999)
+ $connector->create('127.0.0.1', 9999)
->then($this->expectCallableNever(), $this->expectCallableOnce());
$loop->run();
@@ -40,7 +40,7 @@ public function connectionToTcpServerShouldSucceed()
$dns = $this->createResolverMock();
$connector = new Connector($loop, $dns);
- $connector->createTcp('127.0.0.1', 9999)
+ $connector->create('127.0.0.1', 9999)
->then(function ($stream) use (&$capturedStream) {
$capturedStream = $stream;
$stream->end();

0 comments on commit f2bd0d6

Please sign in to comment.