Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatch event when connection is terminated #150

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,5 +57,7 @@ public function send(string $message): void
public function terminate(): void
{
$this->connection->close();

ConnectionTerminated::dispatch($this);
}
}
19 changes: 19 additions & 0 deletions src/Events/ConnectionTerminated.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\Contracts\Connection;

class ConnectionTerminated
{
use Dispatchable;

/**
* Create a new event instance.
*/
public function __construct(public Connection $connection)
{
//
}
}
Loading