Skip to content

Instantly share code, notes, and snippets.

@clue
Last active April 6, 2017 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clue/75d00d9c2ca2e931661c to your computer and use it in GitHub Desktop.
Save clue/75d00d9c2ca2e931661c to your computer and use it in GitHub Desktop.
TimeoutConnector skeleton
<?php
namespace React\SocketClient;
use React\SocketClient\ConnectorInterface;
use React\EventLoop\LoopInterface;
use React\Promise\Timer;
class TimeoutConnector implements ConnectorInterface
{
public function __construct(ConnectorInterface $connector, $timeout, LoopInterface $loop)
{
$this->connector = $connector;
$this->timeout = $timeout;
$this->loop = $loop;
}
public function create($host, $port)
{
return Timer\timeout($this->connector->create($host, $port), $this->timeout, $this->loop);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment