From 22e500d02a99eee614beedb11e15479edb308d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Fri, 10 Mar 2017 15:13:39 +0100 Subject: [PATCH 1/2] Fix event arguments --- src/Ratchet/Server/IoServer.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Ratchet/Server/IoServer.php b/src/Ratchet/Server/IoServer.php index 9cf0798..4031638 100644 --- a/src/Ratchet/Server/IoServer.php +++ b/src/Ratchet/Server/IoServer.php @@ -24,6 +24,7 @@ class IoServer { /** * Array of React event handlers * @var \SplFixedArray + * @deprecated exists BC only, now unused */ protected $handlers; @@ -53,9 +54,6 @@ class IoServer { $socket->on('connection', array($this, 'handleConnect')); $this->handlers = new \SplFixedArray(3); - $this->handlers[0] = array($this, 'handleData'); - $this->handlers[1] = array($this, 'handleEnd'); - $this->handlers[2] = array($this, 'handleError'); } /** @@ -100,9 +98,16 @@ class IoServer { $this->app->onOpen($conn->decor); - $conn->on('data', $this->handlers[0]); - $conn->on('end', $this->handlers[1]); - $conn->on('error', $this->handlers[2]); + $that = $this; + $conn->on('data', function ($data) use ($conn, $that) { + $that->handleData($data, $conn); + }); + $conn->on('close', function () use ($conn, $that) { + $that->handleEnd($conn); + }); + $conn->on('error', function (\Exception $e) use ($conn, $that) { + $that->handleError($e, $conn); + }); } /** From e3a97b66618ce8d2b444b0b56496b0e8a4118b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Mon, 17 Apr 2017 17:36:23 +0200 Subject: [PATCH 2/2] Forward-compatibility with Socket v0.7 and Socket v0.6 Socket v0.7 and v0.6 contain some major changes, but this does not affect usage within Ratchet, so it's actually compatible with all latest releases. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d396d9f..a070212 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ } , "require": { "php": ">=5.3.9" - , "react/socket": "^0.5" + , "react/socket": "^0.7 || ^0.6 || ^0.5" , "guzzle/http": "^3.6" , "symfony/http-foundation": "^2.2|^3.0" , "symfony/routing": "^2.2|^3.0"