From fc97e5bca6faffa5104627c42677b5fceb35477c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20von=20Hoe=C3=9Flin?= Date: Fri, 28 Aug 2020 12:55:02 +0200 Subject: [PATCH 1/2] update requires --- composer.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 5d5375e..bd816b4 100644 --- a/composer.json +++ b/composer.json @@ -12,13 +12,13 @@ ], "require": { "php": ">=5.3", - "clue/socket-raw": "1.* | 0.1.*", - "evenement/evenement": "1.*", - "react/event-loop": ">=0.2, <0.4", - "react/promise": "1.*", - "react/stream": ">=0.2, <0.4", - "react/socket": ">=0.2, <0.4", - "react/datagram": "~1.0" + "clue/socket-raw": "^1.0", + "evenement/evenement": "^3.0", + "react/event-loop": "^1.0", + "react/promise": "^2.0", + "react/stream": "^1.0", + "react/socket": "^1.0", + "react/datagram": "^1.0" }, "autoload": { "psr-4": {"Socket\\React\\": "src"} From d96a1d3b473e89277286978e706a695de9830ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20von=20Hoe=C3=9Flin?= Date: Mon, 31 Aug 2020 17:37:52 +0200 Subject: [PATCH 2/2] fix SocketSelectLoop.php for LoopInterface >= v1.0 --- composer.json | 3 +- src/EventLoop/SocketSelectLoop.php | 49 +++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index bd816b4..4ee6d52 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "react/promise": "^2.0", "react/stream": "^1.0", "react/socket": "^1.0", - "react/datagram": "^1.0" + "react/datagram": "^1.0", + "ext-sockets": "*" }, "autoload": { "psr-4": {"Socket\\React\\": "src"} diff --git a/src/EventLoop/SocketSelectLoop.php b/src/EventLoop/SocketSelectLoop.php index 5402e39..544dbe8 100644 --- a/src/EventLoop/SocketSelectLoop.php +++ b/src/EventLoop/SocketSelectLoop.php @@ -4,7 +4,7 @@ use React\EventLoop\LoopInterface; use React\EventLoop\Timer\Timer; -use React\EventLoop\Timer\TimerInterface; +use React\EventLoop\TimerInterface; use React\EventLoop\Timer\Timers; use InvalidArgumentException; @@ -31,7 +31,7 @@ public function addReadStream($stream, $listener) { $this->assertStream($stream); - $id = (int) $stream; + $id = (int)$stream; if (!isset($this->readStreams[$id])) { $this->readStreams[$id] = $stream; @@ -43,7 +43,7 @@ public function addWriteStream($stream, $listener) { $this->assertStream($stream); - $id = (int) $stream; + $id = (int)$stream; if (!isset($this->writeStreams[$id])) { $this->writeStreams[$id] = $stream; @@ -53,7 +53,7 @@ public function addWriteStream($stream, $listener) public function removeReadStream($stream) { - $id = (int) $stream; + $id = (int)$stream; unset( $this->readStreams[$id], @@ -63,7 +63,7 @@ public function removeReadStream($stream) public function removeWriteStream($stream) { - $id = (int) $stream; + $id = (int)$stream; unset( $this->writeStreams[$id], @@ -79,7 +79,7 @@ public function removeStream($stream) public function addTimer($interval, $callback) { - $timer = new Timer($this, $interval, $callback, false); + $timer = new Timer($interval, $callback, false); $this->timers->add($timer); return $timer; @@ -87,7 +87,7 @@ public function addTimer($interval, $callback) public function addPeriodicTimer($interval, $callback) { - $timer = new Timer($this, $interval, $callback, true); + $timer = new Timer($interval, $callback, true); $this->timers->add($timer); return $timer; @@ -146,18 +146,18 @@ protected function runStreamSelect() if (socket_select($read, $write, $except, 0, $this->getNextEventTimeInMicroSeconds()) > 0) { if ($read) { foreach ($read as $stream) { - $listener = $this->readListeners[(int) $stream]; + $listener = $this->readListeners[(int)$stream]; call_user_func($listener, $stream, $this); } } if ($write) { foreach ($write as $stream) { - if (!isset($this->writeListeners[(int) $stream])) { + if (!isset($this->writeListeners[(int)$stream])) { continue; } - $listener = $this->writeListeners[(int) $stream]; + $listener = $this->writeListeners[(int)$stream]; call_user_func($listener, $stream, $this); } } @@ -202,7 +202,34 @@ private function assertStream($stream) } if (!$checked[$type]) { - throw new InvalidArgumentException('Socket loop only accepts resources of type "Socket", but "' . $type .'" given'); + throw new InvalidArgumentException('Socket loop only accepts resources of type "Socket", but "' . $type . '" given'); } } + + /** + * @inheritDoc + */ + public function futureTick($listener) + { + throw new \Exception('Not implemented yet'); + } + + /** + * @inheritDoc + */ + public function addSignal($signal, $listener) + { + throw new \Exception('Not implemented yet'); + + } + + /** + * @inheritDoc + */ + public function removeSignal($signal, $listener) + { + throw new \Exception('Not implemented yet'); + } + + }