From d4f97e45c1aff437a36830b314bf384cdf86e21f Mon Sep 17 00:00:00 2001 From: freek Date: Mon, 26 Nov 2018 23:15:03 +0100 Subject: [PATCH] fire event on exception --- src/Events/ExceptionThrown.php | 21 +++++++++++++++++++ .../Http/Controllers/EchoController.php | 7 +++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/Events/ExceptionThrown.php diff --git a/src/Events/ExceptionThrown.php b/src/Events/ExceptionThrown.php new file mode 100644 index 0000000..274bbd9 --- /dev/null +++ b/src/Events/ExceptionThrown.php @@ -0,0 +1,21 @@ +connection = $connection; + + $this->exception = $exception; + } +} \ No newline at end of file diff --git a/src/LaravelEcho/Http/Controllers/EchoController.php b/src/LaravelEcho/Http/Controllers/EchoController.php index c27dc6c..3221ebc 100644 --- a/src/LaravelEcho/Http/Controllers/EchoController.php +++ b/src/LaravelEcho/Http/Controllers/EchoController.php @@ -3,17 +3,17 @@ namespace BeyondCode\LaravelWebSockets\LaravelEcho\Http\Controllers; use BeyondCode\LaravelWebSockets\ClientProviders\Client; +use BeyondCode\LaravelWebSockets\Events\ExceptionThrown; use BeyondCode\LaravelWebSockets\QueryParameters; use Exception; use Illuminate\Http\Request; -use GuzzleHttp\Psr7 as gPsr; use GuzzleHttp\Psr7\Response; -use MongoDB\Driver\Query; use Ratchet\ConnectionInterface; use Illuminate\Http\JsonResponse; use GuzzleHttp\Psr7\ServerRequest; use Ratchet\Http\HttpServerInterface; use Psr\Http\Message\RequestInterface; +use SebastianBergmann\ObjectEnumerator\Fixtures\ExceptionThrower; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory; use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Channels\ChannelManager; @@ -60,6 +60,8 @@ abstract class EchoController implements HttpServerInterface function onError(ConnectionInterface $connection, Exception $exception) { + event(new ExceptionThrown($connection, $exception)); + if (! $exception instanceof HttpException) { return; } @@ -71,6 +73,7 @@ abstract class EchoController implements HttpServerInterface ])); $connection->send(Psr\str($response)); + $connection->close(); }