3
3
namespace BeyondCode \LaravelWebSockets \ChannelManagers ;
4
4
5
5
use BeyondCode \LaravelWebSockets \Channels \Channel ;
6
+ use BeyondCode \LaravelWebSockets \DashboardLogger ;
6
7
use BeyondCode \LaravelWebSockets \Helpers ;
7
8
use BeyondCode \LaravelWebSockets \Server \MockableConnection ;
8
9
use Carbon \Carbon ;
@@ -286,6 +287,13 @@ public function broadcastAcrossServers($appId, ?string $socketId, string $channe
286
287
$ payload ->socketId = $ socketId ;
287
288
$ payload ->serverId = $ serverId ?: $ this ->getServerId ();
288
289
290
+ DashboardLogger::log ($ appId , DashboardLogger::TYPE_REPLICATION_MESSAGE_PUBLISHED , [
291
+ 'fromServerId ' => $ serverId ,
292
+ 'fromSocketId ' => $ socketId ,
293
+ 'channel ' => $ channel ,
294
+ 'payload ' => $ payload ,
295
+ ]);
296
+
289
297
return $ this ->publishClient
290
298
->publish ($ this ->getRedisKey ($ appId , $ channel ), json_encode ($ payload ))
291
299
->then (function () use ($ appId , $ socketId , $ channel , $ payload , $ serverId ) {
@@ -464,6 +472,14 @@ public function onMessage(string $redisChannel, string $payload)
464
472
$ socketId = $ payload ->socketId ?? null ;
465
473
$ serverId = $ payload ->serverId ?? null ;
466
474
475
+ DashboardLogger::log ($ appId , DashboardLogger::TYPE_REPLICATOR_MESSAGE_RECEIVED , [
476
+ 'fromServerId ' => $ serverId ,
477
+ 'fromSocketId ' => $ socketId ,
478
+ 'receiverServerId ' => $ this ->getServerId (),
479
+ 'channel ' => $ channel ,
480
+ 'payload ' => $ payload ,
481
+ ]);
482
+
467
483
unset($ payload ->socketId );
468
484
unset($ payload ->serverId );
469
485
unset($ payload ->appId );
@@ -693,9 +709,14 @@ public function removeUserData($appId, string $channel = null, string $key): Pro
693
709
*/
694
710
public function subscribeToTopic ($ appId , string $ channel = null ): PromiseInterface
695
711
{
696
- return $ this ->subscribeClient ->subscribe (
697
- $ this ->getRedisKey ($ appId , $ channel )
698
- );
712
+ $ topic = $ this ->getRedisKey ($ appId , $ channel );
713
+
714
+ DashboardLogger::log ($ appId , DashboardLogger::TYPE_REPLICATOR_SUBSCRIBED , [
715
+ 'serverId ' => $ this ->getServerId (),
716
+ 'pubsubTopic ' => $ topic ,
717
+ ]);
718
+
719
+ return $ this ->subscribeClient ->subscribe ($ topic );
699
720
}
700
721
701
722
/**
@@ -707,9 +728,14 @@ public function subscribeToTopic($appId, string $channel = null): PromiseInterfa
707
728
*/
708
729
public function unsubscribeFromTopic ($ appId , string $ channel = null ): PromiseInterface
709
730
{
710
- return $ this ->subscribeClient ->unsubscribe (
711
- $ this ->getRedisKey ($ appId , $ channel )
712
- );
731
+ $ topic = $ this ->getRedisKey ($ appId , $ channel );
732
+
733
+ DashboardLogger::log ($ appId , DashboardLogger::TYPE_REPLICATOR_UNSUBSCRIBED , [
734
+ 'serverId ' => $ this ->getServerId (),
735
+ 'pubsubTopic ' => $ topic ,
736
+ ]);
737
+
738
+ return $ this ->subscribeClient ->unsubscribe ($ topic );
713
739
}
714
740
715
741
/**
0 commit comments