diff --git a/config/websockets.php b/config/websockets.php index 1c9f61f2f7..a798251d5f 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -141,6 +141,24 @@ ], + /* + |-------------------------------------------------------------------------- + | Route Handlers + |-------------------------------------------------------------------------- + | + | Here you can specify the route handlers that will take over + | the incoming/outgoing websocket connections. You can extend the + | original class and implement your own logic, alongside + | with the existing logic. + | + */ + + 'handlers' => [ + + 'websocket' => \BeyondCode\LaravelWebSockets\WebSockets\WebSocketHandler::class, + + ], + /* |-------------------------------------------------------------------------- | Broadcasting Replication PubSub @@ -148,7 +166,7 @@ | | You can enable replication to publish and subscribe to | messages across the driver. - + | | By default, it is set to 'local', but you can configure it to use drivers | like Redis to ensure connection between multiple instances of | WebSocket servers. Just set the driver to 'redis' to enable the PubSub using Redis. diff --git a/src/Server/Router.php b/src/Server/Router.php index ce56bd4a72..bda51f174a 100644 --- a/src/Server/Router.php +++ b/src/Server/Router.php @@ -34,7 +34,7 @@ public function getRoutes(): RouteCollection public function echo() { - $this->get('/app/{appKey}', WebSocketHandler::class); + $this->get('/app/{appKey}', config('websockets.handlers.websocket', WebSocketHandler::class)); $this->post('/apps/{appId}/events', TriggerEventController::class); $this->get('/apps/{appId}/channels', FetchChannelsController::class); diff --git a/tests/TestCase.php b/tests/TestCase.php index 7070aa49b5..4ad82dd83c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -10,7 +10,6 @@ use BeyondCode\LaravelWebSockets\Tests\Mocks\Message; use BeyondCode\LaravelWebSockets\Tests\Statistics\Logger\FakeStatisticsLogger; use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; -use BeyondCode\LaravelWebSockets\WebSockets\WebSocketHandler; use Clue\React\Buzz\Browser; use GuzzleHttp\Psr7\Request; use Mockery; @@ -32,7 +31,7 @@ public function setUp(): void { parent::setUp(); - $this->pusherServer = app(WebSocketHandler::class); + $this->pusherServer = app(config('websockets.handlers.websocket')); $this->channelManager = app(ChannelManager::class);