Skip to content

Commit

Permalink
Dispatch an event when a connection is pruned. (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
joekaram authored Aug 1, 2024
1 parent 8383876 commit 7f86ad1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Events/ConnectionPruned.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Laravel\Reverb\Events;

use Illuminate\Foundation\Events\Dispatchable;
use Laravel\Reverb\Protocols\Pusher\Channels\ChannelConnection;

class ConnectionPruned
{
use Dispatchable;

/**
* Create a new event instance.
*/
public function __construct(public ChannelConnection $connection)
{
//
}
}
3 changes: 3 additions & 0 deletions src/Jobs/PruneStaleConnections.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Foundation\Bus\Dispatchable;
use Laravel\Reverb\Contracts\ApplicationProvider;
use Laravel\Reverb\Events\ConnectionPruned;
use Laravel\Reverb\Loggers\Log;
use Laravel\Reverb\Protocols\Pusher\Contracts\ChannelManager;

Expand Down Expand Up @@ -41,6 +42,8 @@ public function handle(ChannelManager $channels): void
$connection->disconnect();

Log::info('Connection Pruned', $connection->id());

ConnectionPruned::dispatch($connection);
}
});
}
Expand Down

0 comments on commit 7f86ad1

Please sign in to comment.