Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 9745ca1

Browse files
authored
Merge pull request #465 from beyondcode/feature/extendable-hook
[2.x] Extendable hook
2 parents 99a48d5 + 13978cb commit 9745ca1

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

config/websockets.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,32 @@
141141

142142
],
143143

144+
/*
145+
|--------------------------------------------------------------------------
146+
| Route Handlers
147+
|--------------------------------------------------------------------------
148+
|
149+
| Here you can specify the route handlers that will take over
150+
| the incoming/outgoing websocket connections. You can extend the
151+
| original class and implement your own logic, alongside
152+
| with the existing logic.
153+
|
154+
*/
155+
156+
'handlers' => [
157+
158+
'websocket' => \BeyondCode\LaravelWebSockets\WebSockets\WebSocketHandler::class,
159+
160+
],
161+
144162
/*
145163
|--------------------------------------------------------------------------
146164
| Broadcasting Replication PubSub
147165
|--------------------------------------------------------------------------
148166
|
149167
| You can enable replication to publish and subscribe to
150168
| messages across the driver.
151-
169+
|
152170
| By default, it is set to 'local', but you can configure it to use drivers
153171
| like Redis to ensure connection between multiple instances of
154172
| WebSocket servers. Just set the driver to 'redis' to enable the PubSub using Redis.

src/Server/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getRoutes(): RouteCollection
3434

3535
public function echo()
3636
{
37-
$this->get('/app/{appKey}', WebSocketHandler::class);
37+
$this->get('/app/{appKey}', config('websockets.handlers.websocket', WebSocketHandler::class));
3838

3939
$this->post('/apps/{appId}/events', TriggerEventController::class);
4040
$this->get('/apps/{appId}/channels', FetchChannelsController::class);

tests/TestCase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use BeyondCode\LaravelWebSockets\Tests\Mocks\Message;
1111
use BeyondCode\LaravelWebSockets\Tests\Statistics\Logger\FakeStatisticsLogger;
1212
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
13-
use BeyondCode\LaravelWebSockets\WebSockets\WebSocketHandler;
1413
use Clue\React\Buzz\Browser;
1514
use GuzzleHttp\Psr7\Request;
1615
use Mockery;
@@ -32,7 +31,7 @@ public function setUp(): void
3231
{
3332
parent::setUp();
3433

35-
$this->pusherServer = app(WebSocketHandler::class);
34+
$this->pusherServer = app(config('websockets.handlers.websocket'));
3635

3736
$this->channelManager = app(ChannelManager::class);
3837

0 commit comments

Comments
 (0)