fire event on exception
This commit is contained in:
parent
ef67261cb5
commit
d4f97e45c1
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BeyondCode\LaravelWebSockets\Events;
|
||||||
|
|
||||||
|
use Ratchet\ConnectionInterface;
|
||||||
|
|
||||||
|
class ExceptionThrown
|
||||||
|
{
|
||||||
|
/** @var \Ratchet\ConnectionInterface */
|
||||||
|
public $connection;
|
||||||
|
|
||||||
|
/** @var \Exception */
|
||||||
|
public $exception;
|
||||||
|
|
||||||
|
public function __construct(ConnectionInterface $connection, \Exception $exception)
|
||||||
|
{
|
||||||
|
$this->connection = $connection;
|
||||||
|
|
||||||
|
$this->exception = $exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,17 +3,17 @@
|
||||||
namespace BeyondCode\LaravelWebSockets\LaravelEcho\Http\Controllers;
|
namespace BeyondCode\LaravelWebSockets\LaravelEcho\Http\Controllers;
|
||||||
|
|
||||||
use BeyondCode\LaravelWebSockets\ClientProviders\Client;
|
use BeyondCode\LaravelWebSockets\ClientProviders\Client;
|
||||||
|
use BeyondCode\LaravelWebSockets\Events\ExceptionThrown;
|
||||||
use BeyondCode\LaravelWebSockets\QueryParameters;
|
use BeyondCode\LaravelWebSockets\QueryParameters;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use GuzzleHttp\Psr7 as gPsr;
|
|
||||||
use GuzzleHttp\Psr7\Response;
|
use GuzzleHttp\Psr7\Response;
|
||||||
use MongoDB\Driver\Query;
|
|
||||||
use Ratchet\ConnectionInterface;
|
use Ratchet\ConnectionInterface;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use GuzzleHttp\Psr7\ServerRequest;
|
use GuzzleHttp\Psr7\ServerRequest;
|
||||||
use Ratchet\Http\HttpServerInterface;
|
use Ratchet\Http\HttpServerInterface;
|
||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
|
use SebastianBergmann\ObjectEnumerator\Fixtures\ExceptionThrower;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
|
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
|
||||||
use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Channels\ChannelManager;
|
use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Channels\ChannelManager;
|
||||||
|
|
@ -60,6 +60,8 @@ abstract class EchoController implements HttpServerInterface
|
||||||
|
|
||||||
function onError(ConnectionInterface $connection, Exception $exception)
|
function onError(ConnectionInterface $connection, Exception $exception)
|
||||||
{
|
{
|
||||||
|
event(new ExceptionThrown($connection, $exception));
|
||||||
|
|
||||||
if (! $exception instanceof HttpException) {
|
if (! $exception instanceof HttpException) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -71,6 +73,7 @@ abstract class EchoController implements HttpServerInterface
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$connection->send(Psr\str($response));
|
$connection->send(Psr\str($response));
|
||||||
|
|
||||||
$connection->close();
|
$connection->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue