Skip to content

Commit

Permalink
Use version in resume url (#82)
Browse files Browse the repository at this point in the history
* Experimental fix for attaching version to resume URL

* Fix tests
  • Loading branch information
Exanlv committed Mar 17, 2024
1 parent 1ee640d commit e903967
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Gateway/Connection.php
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Gateway/ConnectionTest.php
Expand Up @@ -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
Expand Down Expand Up @@ -73,7 +73,7 @@ public function testConnect(): void

$websocket->expects()
->open()
->with('::ws url::')
->with('::ws url::?v=10')
->andReturns(PromiseFake::get('::return::'))
->once();

Expand Down

0 comments on commit e903967

Please sign in to comment.