From 1f9f4d1418c40ae19dc1ad2c3ddd215b0a599e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Mon, 30 Aug 2021 12:10:35 +0200 Subject: [PATCH] Simplify usage by supporting new Socket API --- README.md | 4 ++-- composer.json | 3 +-- src/Connector.php | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2f3d013..15b1039 100644 --- a/README.md +++ b/README.md @@ -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']) diff --git a/composer.json b/composer.json index 5095c1c..42b7260 100644 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/src/Connector.php b/src/Connector.php index d318f67..8fd0519 100644 --- a/src/Connector.php +++ b/src/Connector.php @@ -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;