Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
, "require": {
"php": ">=5.4.2"
, "ratchet/rfc6455": "^0.3.1"
, "ratchet/rfc6455": "^0.4.0 | ^0.3.1"
, "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5"
, "react/event-loop": "^1.0 || ^0.5 || ^0.4"
, "guzzlehttp/psr7": "^1.7|^2.0"
Expand Down
14 changes: 13 additions & 1 deletion src/Ratchet/WebSocket/WsServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Ratchet\RFC6455\Handshake\ServerNegotiator;
use Ratchet\RFC6455\Handshake\RequestVerifier;
use React\EventLoop\LoopInterface;
use GuzzleHttp\Psr7\HttpFactory;
use GuzzleHttp\Psr7\Message;

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

$this->closeFrameChecker = new CloseFrameChecker;
$this->handshakeNegotiator = new ServerNegotiator(new RequestVerifier);

if (self::isRFC6455v03()) {
$this->handshakeNegotiator = new ServerNegotiator(new RequestVerifier);
} else {
$this->handshakeNegotiator = new ServerNegotiator(new RequestVerifier, new HttpFactory);
}

$this->handshakeNegotiator->setStrictSubProtocolCheck(true);

if ($component instanceof WsServerInterface) {
Expand All @@ -101,6 +108,11 @@ public function __construct(ComponentInterface $component) {
};
}

private static function isRFC6455v03() {
$reflection = new \ReflectionClass('Ratchet\RFC6455\Handshake\ServerNegotiator');
return $reflection->getMethod('__construct')->getNumberOfRequiredParameters() === 1;
}

/**
* {@inheritdoc}
*/
Expand Down