summaryrefslogtreecommitdiffstats
path: root/vendor/clue/connection-manager-extra/src/ConnectionManagerDelay.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/clue/connection-manager-extra/src/ConnectionManagerDelay.php')
-rw-r--r--vendor/clue/connection-manager-extra/src/ConnectionManagerDelay.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/clue/connection-manager-extra/src/ConnectionManagerDelay.php b/vendor/clue/connection-manager-extra/src/ConnectionManagerDelay.php
new file mode 100644
index 0000000..b5112c6
--- /dev/null
+++ b/vendor/clue/connection-manager-extra/src/ConnectionManagerDelay.php
@@ -0,0 +1,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);
+ });
+ }
+}