Skip to content

Commit

Permalink
Simplify usage by supporting new Socket API
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Aug 30, 2021
1 parent 3ddf9fe commit 1f9f4d1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ A more in-depth example using explicit interfaces: Requesting sub-protocols, and

require __DIR__ . '/vendor/autoload.php';

$loop = \React\EventLoop\Loop::get();
$reactConnector = new \React\Socket\Connector($loop, [
$reactConnector = new \React\Socket\Connector([
'dns' => '8.8.8.8',
'timeout' => 10
]);
$loop = \React\EventLoop\Loop::get();
$connector = new \Ratchet\Client\Connector($loop, $reactConnector);

$connector('ws://127.0.0.1:9000', ['protocol1', 'subprotocol2'], ['Origin' => 'http://localhost'])
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"php": ">=5.4"
, "evenement/evenement": "^3.0 || ^2.0"
, "ratchet/rfc6455": "^0.3"
, "react/event-loop": "^1.2"
, "react/socket": "^1.0 || ^0.8 || ^0.7"
, "react/socket": "^1.9"
}
, "require-dev": {
"phpunit/phpunit": "~4.8"
Expand Down
4 changes: 2 additions & 2 deletions src/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public function __construct(LoopInterface $loop = null, ConnectorInterface $conn
$this->_loop = $loop ?: Loop::get();

if (null === $connector) {
$connector = new \React\Socket\Connector($this->_loop, [
$connector = new \React\Socket\Connector([
'timeout' => 20
]);
], $this->_loop);
}

$this->_connector = $connector;
Expand Down

0 comments on commit 1f9f4d1

Please sign in to comment.