diff --git a/composer.json b/composer.json index a070212..993e4c7 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ } , "require": { "php": ">=5.3.9" - , "react/socket": "^0.7 || ^0.6 || ^0.5" + , "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5" , "guzzle/http": "^3.6" , "symfony/http-foundation": "^2.2|^3.0" , "symfony/routing": "^2.2|^3.0" diff --git a/src/Ratchet/Server/IoServer.php b/src/Ratchet/Server/IoServer.php index 4031638..3fcf76c 100644 --- a/src/Ratchet/Server/IoServer.php +++ b/src/Ratchet/Server/IoServer.php @@ -89,10 +89,11 @@ class IoServer { */ public function handleConnect($conn) { $conn->decor = new IoConnection($conn); - $conn->decor->resourceId = (int)$conn->stream; + + $uri = $conn->getRemoteAddress(); $conn->decor->remoteAddress = trim( - parse_url('tcp://' . $conn->getRemoteAddress(), PHP_URL_HOST), + parse_url((strpos($uri, '://') === false ? 'tcp://' : '') . $uri, PHP_URL_HOST), '[]' ); diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index ec54b5d..284fbde 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -22,7 +22,8 @@ class IoServerTest extends \PHPUnit_Framework_TestCase { $loop = new StreamSelectLoop; $this->reactor = new Server(0, $loop); - $this->port = parse_url('tcp://' . $this->reactor->getAddress(), PHP_URL_PORT); + $uri = $this->reactor->getAddress(); + $this->port = parse_url((strpos($uri, '://') === false ? 'tcp://' : '') . $uri, PHP_URL_PORT); $this->server = new IoServer($this->app, $this->reactor, $loop); }