From 786e180b0f4a47b3a40ba4672db188b21eb211fd Mon Sep 17 00:00:00 2001 From: Amir Reza Mehbakhsh Date: Sun, 14 Apr 2024 00:00:20 +0200 Subject: [PATCH] Dispatch event when connection is terminated --- src/Connection.php | 3 +++ src/Events/ConnectionTerminated.php | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/Events/ConnectionTerminated.php diff --git a/src/Connection.php b/src/Connection.php index 8cf9c176..2ca5e3d0 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -4,6 +4,7 @@ use Laravel\Reverb\Concerns\GeneratesIdentifiers; use Laravel\Reverb\Contracts\Connection as ConnectionContract; +use Laravel\Reverb\Events\ConnectionTerminated; use Laravel\Reverb\Events\MessageSent; class Connection extends ConnectionContract @@ -56,5 +57,7 @@ public function send(string $message): void public function terminate(): void { $this->connection->close(); + + ConnectionTerminated::dispatch($this); } } diff --git a/src/Events/ConnectionTerminated.php b/src/Events/ConnectionTerminated.php new file mode 100644 index 00000000..f5baae60 --- /dev/null +++ b/src/Events/ConnectionTerminated.php @@ -0,0 +1,19 @@ +