use event

This commit is contained in:
freek 2018-11-26 09:22:30 +01:00
parent 11ab7ac21a
commit adcd300a94
3 changed files with 12 additions and 2 deletions

View File

@ -0,0 +1,8 @@
<?php
namespace BeyondCode\LaravelWebSockets\Dashboard;
class EventHandler
{
//TODO: listen for events, pass them to Dashboard:: methods
}

View File

@ -5,10 +5,10 @@ namespace BeyondCode\LaravelWebSockets\Events;
class ChannelVacated class ChannelVacated
{ {
/** @var \BeyondCode\LaravelWebSockets\Events\ConnectionInterface */ /** @var \BeyondCode\LaravelWebSockets\Events\ConnectionInterface */
protected $connection; public $connection;
/** @var string */ /** @var string */
protected $channelId; public $channelId;
public function __construct(ConnectionInterface $connection, string $channelId) public function __construct(ConnectionInterface $connection, string $channelId)
{ {

View File

@ -2,6 +2,7 @@
namespace BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Channels; namespace BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Channels;
use BeyondCode\LaravelWebSockets\Events\ChannelVacated;
use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Dashboard; use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Dashboard;
use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Exceptions\InvalidSignatureException; use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Exceptions\InvalidSignatureException;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@ -59,6 +60,7 @@ class Channel
unset($this->subscriptions[$connection->socketId]); unset($this->subscriptions[$connection->socketId]);
if (! $this->hasConnections()) { if (! $this->hasConnections()) {
event(new ChannelVacated($connection, $this->channelId));
Dashboard::vacated($connection, $this->channelId); Dashboard::vacated($connection, $this->channelId);
} }
} }