mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-05 19:41:55 +02:00
Move from React 0.4.0 to 0.3.4 for PHP 5.3 compatibility reasons
This commit is contained in:
parent
d3f01a3bc7
commit
7f82bea13e
50 changed files with 608 additions and 1937 deletions
|
@ -5,7 +5,7 @@ namespace React\SocketClient;
|
|||
use React\EventLoop\LoopInterface;
|
||||
use React\Dns\Resolver\Resolver;
|
||||
use React\Stream\Stream;
|
||||
use React\Promise;
|
||||
use React\Promise\When;
|
||||
use React\Promise\Deferred;
|
||||
|
||||
class Connector implements ConnectorInterface
|
||||
|
@ -21,10 +21,12 @@ class Connector implements ConnectorInterface
|
|||
|
||||
public function create($host, $port)
|
||||
{
|
||||
$that = $this;
|
||||
|
||||
return $this
|
||||
->resolveHostname($host)
|
||||
->then(function ($address) use ($port) {
|
||||
return $this->createSocketForAddress($address, $port);
|
||||
->then(function ($address) use ($port, $that) {
|
||||
return $that->createSocketForAddress($address, $port);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -35,7 +37,7 @@ class Connector implements ConnectorInterface
|
|||
$socket = stream_socket_client($url, $errno, $errstr, 0, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);
|
||||
|
||||
if (!$socket) {
|
||||
return Promise\reject(new \RuntimeException(
|
||||
return When::reject(new \RuntimeException(
|
||||
sprintf("connection to %s:%d failed: %s", $address, $port, $errstr),
|
||||
$errno
|
||||
));
|
||||
|
@ -71,10 +73,10 @@ class Connector implements ConnectorInterface
|
|||
// The following hack looks like the only way to
|
||||
// detect connection refused errors with PHP's stream sockets.
|
||||
if (false === stream_socket_get_name($socket, true)) {
|
||||
return Promise\reject(new ConnectionException('Connection refused'));
|
||||
return When::reject(new ConnectionException('Connection refused'));
|
||||
}
|
||||
|
||||
return Promise\resolve($socket);
|
||||
return When::resolve($socket);
|
||||
}
|
||||
|
||||
public function handleConnectedSocket($socket)
|
||||
|
@ -94,7 +96,7 @@ class Connector implements ConnectorInterface
|
|||
protected function resolveHostname($host)
|
||||
{
|
||||
if (false !== filter_var($host, FILTER_VALIDATE_IP)) {
|
||||
return Promise\resolve($host);
|
||||
return When::resolve($host);
|
||||
}
|
||||
|
||||
return $this->resolver->resolve($host);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue