diff --git a/src/Gateway/Connection.php b/src/Gateway/Connection.php index 7a431df..333e752 100644 --- a/src/Gateway/Connection.php +++ b/src/Gateway/Connection.php @@ -34,7 +34,8 @@ */ class Connection implements ConnectionInterface { - public const DEFAULT_WEBSOCKET_URL = 'wss://gateway.discord.gg/?v=10'; + public const DEFAULT_WEBSOCKET_URL = 'wss://gateway.discord.gg/'; + private const QUERY_DATA = ['v' => 10]; private const HEARTBEAT_ACK_TIMEOUT = 2.5; @@ -116,6 +117,8 @@ public function resetSequence(): void public function connect(string $url): ExtendedPromiseInterface { + $url .= '?' . http_build_query(self::QUERY_DATA); + return $this->websocket->open($url); } diff --git a/tests/Gateway/ConnectionTest.php b/tests/Gateway/ConnectionTest.php index e9de649..517d578 100644 --- a/tests/Gateway/ConnectionTest.php +++ b/tests/Gateway/ConnectionTest.php @@ -37,7 +37,7 @@ public function testGetDefaultUrl(): void new DataMapper(new NullLogger()) ); - $this->assertMatchesRegularExpression('/wss:\/\/gateway.discord.gg\/\?v=(\d+)/', $connection->getDefaultUrl()); + $this->assertEquals('wss://gateway.discord.gg/', $connection->getDefaultUrl()); } public function testSequence(): void @@ -73,7 +73,7 @@ public function testConnect(): void $websocket->expects() ->open() - ->with('::ws url::') + ->with('::ws url::?v=10') ->andReturns(PromiseFake::get('::return::')) ->once();