blob: b5112c6172717d9f998fa658aa6fa78cafb7fa82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
namespace ConnectionManager\Extra;
use React\Socket\ConnectorInterface;
use React\EventLoop\LoopInterface;
use React\Promise\Timer;
class ConnectionManagerDelay implements ConnectorInterface
{
private $connectionManager;
private $delay;
private $loop;
public function __construct(ConnectorInterface $connectionManager, $delay, LoopInterface $loop)
{
$this->connectionManager = $connectionManager;
$this->delay = $delay;
$this->loop = $loop;
}
public function connect($uri)
{
$connectionManager = $this->connectionManager;
return Timer\resolve($this->delay, $this->loop)->then(function () use ($connectionManager, $uri) {
return $connectionManager->connect($uri);
});
}
}
|