Skip to content

Commit 9ac6a41

Browse files
authored
Merge pull request #1112 from jaapio/fix/RFC6455-04
Allow usage of ratchet/rfc6455 0.4+
2 parents 2032bb0 + d5e8555 commit 9ac6a41

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
, "require": {
2929
"php": ">=5.4.2"
30-
, "ratchet/rfc6455": "^0.3.1"
30+
, "ratchet/rfc6455": "^0.4.0 | ^0.3.1"
3131
, "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5"
3232
, "react/event-loop": "^1.0 || ^0.5 || ^0.4"
3333
, "guzzlehttp/psr7": "^1.7|^2.0"

src/Ratchet/WebSocket/WsServer.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Ratchet\RFC6455\Handshake\ServerNegotiator;
1515
use Ratchet\RFC6455\Handshake\RequestVerifier;
1616
use React\EventLoop\LoopInterface;
17+
use GuzzleHttp\Psr7\HttpFactory;
1718
use GuzzleHttp\Psr7\Message;
1819

1920
/**
@@ -86,7 +87,13 @@ public function __construct(ComponentInterface $component) {
8687
$this->connections = new \SplObjectStorage;
8788

8889
$this->closeFrameChecker = new CloseFrameChecker;
89-
$this->handshakeNegotiator = new ServerNegotiator(new RequestVerifier);
90+
91+
if (self::isRFC6455v03()) {
92+
$this->handshakeNegotiator = new ServerNegotiator(new RequestVerifier);
93+
} else {
94+
$this->handshakeNegotiator = new ServerNegotiator(new RequestVerifier, new HttpFactory);
95+
}
96+
9097
$this->handshakeNegotiator->setStrictSubProtocolCheck(true);
9198

9299
if ($component instanceof WsServerInterface) {
@@ -101,6 +108,11 @@ public function __construct(ComponentInterface $component) {
101108
};
102109
}
103110

111+
private static function isRFC6455v03() {
112+
$reflection = new \ReflectionClass('Ratchet\RFC6455\Handshake\ServerNegotiator');
113+
return $reflection->getMethod('__construct')->getNumberOfRequiredParameters() === 1;
114+
}
115+
104116
/**
105117
* {@inheritdoc}
106118
*/

0 commit comments

Comments
 (0)