33namespace BeyondCode \LaravelWebSockets \ChannelManagers ;
44
55use BeyondCode \LaravelWebSockets \Channels \Channel ;
6+ use BeyondCode \LaravelWebSockets \DashboardLogger ;
67use BeyondCode \LaravelWebSockets \Helpers ;
78use BeyondCode \LaravelWebSockets \Server \MockableConnection ;
89use Carbon \Carbon ;
@@ -286,6 +287,13 @@ public function broadcastAcrossServers($appId, ?string $socketId, string $channe
286287 $ payload ->socketId = $ socketId ;
287288 $ payload ->serverId = $ serverId ?: $ this ->getServerId ();
288289
290+ DashboardLogger::log ($ appId , DashboardLogger::TYPE_REPLICATION_MESSAGE_PUBLISHED , [
291+ 'fromServerId ' => $ serverId ,
292+ 'fromSocketId ' => $ socketId ,
293+ 'channel ' => $ channel ,
294+ 'payload ' => $ payload ,
295+ ]);
296+
289297 return $ this ->publishClient
290298 ->publish ($ this ->getRedisKey ($ appId , $ channel ), json_encode ($ payload ))
291299 ->then (function () use ($ appId , $ socketId , $ channel , $ payload , $ serverId ) {
@@ -464,6 +472,14 @@ public function onMessage(string $redisChannel, string $payload)
464472 $ socketId = $ payload ->socketId ?? null ;
465473 $ serverId = $ payload ->serverId ?? null ;
466474
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+
467483 unset($ payload ->socketId );
468484 unset($ payload ->serverId );
469485 unset($ payload ->appId );
@@ -693,9 +709,14 @@ public function removeUserData($appId, string $channel = null, string $key): Pro
693709 */
694710 public function subscribeToTopic ($ appId , string $ channel = null ): PromiseInterface
695711 {
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 );
699720 }
700721
701722 /**
@@ -707,9 +728,14 @@ public function subscribeToTopic($appId, string $channel = null): PromiseInterfa
707728 */
708729 public function unsubscribeFromTopic ($ appId , string $ channel = null ): PromiseInterface
709730 {
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 );
713739 }
714740
715741 /**
0 commit comments