Skip to content

Commit

Permalink
handle pings
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon committed Nov 24, 2023
1 parent f213c38 commit 9ea5c45
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/Contracts/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public function origin(): ?string
public function ping(): void
{
$this->hasBeenPinged = true;

// $this->pusher->ping($this);
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src/Jobs/PingInactiveConnections.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Foundation\Bus\Dispatchable;
use Laravel\Reverb\Contracts\ApplicationProvider;
use Laravel\Reverb\Contracts\ChannelManager;
use Laravel\Reverb\Pusher\Event as PusherEvent;

class PingInactiveConnections
{
Expand All @@ -15,15 +16,17 @@ class PingInactiveConnections
*/
public function handle(ChannelManager $channels): void
{
$pusher = new PusherEvent($channels);

app(ApplicationProvider::class)
->all()
->each(function ($application) use ($channels) {
->each(function ($application) use ($channels, $pusher) {
foreach ($channels->for($application)->connections() as $connection) {
if ($connection->isActive()) {
return;
}

$connection->ping();
$pusher->ping($connection);
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/Pusher/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public function pong(Connection $connection): void
public function ping(Connection $connection): void
{
static::send($connection, 'ping');

$connection->ping();
}

/**
Expand Down

0 comments on commit 9ea5c45

Please sign in to comment.