diff --git a/src/Ratchet/Session/SessionProvider.php b/src/Ratchet/Session/SessionProvider.php index cda8723..0fffd71 100644 --- a/src/Ratchet/Session/SessionProvider.php +++ b/src/Ratchet/Session/SessionProvider.php @@ -71,7 +71,7 @@ class SessionProvider implements MessageComponentInterface, WsServerInterface { * {@inheritdoc} */ function onOpen(ConnectionInterface $conn) { - if (null === ($id = $conn->WebSocket->headers->getCookie(ini_get('session.name')))) { + if (null === ($id = $conn->WebSocket->request->getCookie(ini_get('session.name')))) { $saveHandler = $this->_null; $id = ''; } else { diff --git a/src/Ratchet/WebSocket/WsServer.php b/src/Ratchet/WebSocket/WsServer.php index 90cf305..efdabfc 100644 --- a/src/Ratchet/WebSocket/WsServer.php +++ b/src/Ratchet/WebSocket/WsServer.php @@ -93,7 +93,9 @@ class WsServer implements MessageComponentInterface { return $this->close($from); } + $from->WebSocket->request = $request; $from->WebSocket->version = $this->versioner->getVersion($request); + $response = $from->WebSocket->version->handshake($request); $response->setHeader('X-Powered-By', \Ratchet\VERSION); diff --git a/tests/Ratchet/Tests/Session/SessionComponentTest.php b/tests/Ratchet/Tests/Session/SessionComponentTest.php index 5594c06..7e8382a 100644 --- a/tests/Ratchet/Tests/Session/SessionComponentTest.php +++ b/tests/Ratchet/Tests/Session/SessionComponentTest.php @@ -67,7 +67,7 @@ class SessionProviderTest extends \PHPUnit_Framework_TestCase { $headers->expects($this->once())->method('getCookie', array(ini_get('session.name')))->will($this->returnValue($sessionId)); $connection->WebSocket = new \StdClass; - $connection->WebSocket->headers = $headers; + $connection->WebSocket->request = $headers; $component->onOpen($connection); @@ -83,7 +83,7 @@ class SessionProviderTest extends \PHPUnit_Framework_TestCase { $headers->expects($this->once())->method('getCookie', array(ini_get('session.name')))->will($this->returnValue(null)); $conns[$i]->WebSocket = new \StdClass; - $conns[$i]->WebSocket->headers = $headers; + $conns[$i]->WebSocket->request = $headers; } $mock = new MockComponent;