Skip to content

Commit

Permalink
This update introduced the activity_timeout configuration to use in…
Browse files Browse the repository at this point in the history
…stead of `ping_interval` to separate the concerns and accomplish the same result.
  • Loading branch information
zeke0816 committed Aug 16, 2024
1 parent c227158 commit 76339b4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config/reverb.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
],
'allowed_origins' => ['*'],
'ping_interval' => env('REVERB_APP_PING_INTERVAL', 30),
'ping_interval' => env('REVERB_APP_PING_INTERVAL', 60),
'activity_timeout' => env('REVERB_APP_ACTIVITY_TIMEOUT', 30),
'max_message_size' => env('REVERB_APP_MAX_MESSAGE_SIZE', 10_000),
],
],
Expand Down
10 changes: 10 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function __construct(
protected string $key,
protected string $secret,
protected int $pingInterval,
protected int $activityTimeout,
protected array $allowedOrigins,
protected int $maxMessageSize,
protected array $options = [],
Expand Down Expand Up @@ -61,6 +62,14 @@ public function pingInterval(): int
return $this->pingInterval;
}

/**
* Get the activity timeout in seconds to ping the server.
*/
public function activityTimeout(): int
{
return $this->activityTimeout;
}

/**
* Get the maximum message size allowed from the client.
*/
Expand Down Expand Up @@ -89,6 +98,7 @@ public function toArray(): array
'key' => $this->key,
'secret' => $this->secret,
'ping_interval' => $this->pingInterval,
'activity_timeout' => $this->activityTimeout,
'allowed_origins' => $this->allowedOrigins,
'max_message_size' => $this->maxMessageSize,
'options' => $this->options,
Expand Down
1 change: 1 addition & 0 deletions src/ConfigApplicationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function find(string $key, mixed $value): Application
$app['key'],
$app['secret'],
$app['ping_interval'],
$app['activity_timeout'],
$app['allowed_origins'],
$app['max_message_size'],
$app['options'] ?? [],
Expand Down
2 changes: 1 addition & 1 deletion src/Protocols/Pusher/EventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function acknowledge(Connection $connection): void
{
$this->send($connection, 'connection_established', [
'socket_id' => $connection->id(),
'activity_timeout' => $connection->app()->pingInterval(),
'activity_timeout' => $connection->app()->activityTimeout(),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/FakeApplicationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FakeApplicationProvider implements ApplicationProvider
public function __construct()
{
$this->apps = collect([
new Application('id', 'key', 'secret', 60, ['*'], 10_000, [
new Application('id', 'key', 'secret', 60, 30, ['*'], 10_000, [
'host' => 'localhost',
'port' => 443,
'scheme' => 'https',
Expand Down

0 comments on commit 76339b4

Please sign in to comment.