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

Commit 546c4fd

Browse files
committed
Broadcast both locally and across servers on dashboard logger.
1 parent 7519da4 commit 546c4fd

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/Channels/Channel.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ public function broadcast($appId, stdClass $payload, bool $replicate = true): bo
136136
return true;
137137
}
138138

139+
/**
140+
* Broadcast a payload to the locally-subscribed connections.
141+
*
142+
* @param string|int $appId
143+
* @param \stdClass $payload
144+
* @return bool
145+
*/
146+
public function broadcastLocally($appId, stdClass $payload): bool
147+
{
148+
return $this->broadcast($appId, $payload, false);
149+
}
150+
139151
/**
140152
* Broadcast the payload, but exclude a specific socket id.
141153
*

src/DashboardLogger.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,13 @@ public static function log($appId, string $type, array $details = [])
8383
$channel = $channelManager->find($appId, $channelName);
8484

8585
if ($channel) {
86-
$channel->broadcastToEveryoneExcept(
87-
(object) $payload,
88-
null,
89-
$appId
90-
);
91-
} else {
92-
$channelManager->broadcastAcrossServers(
93-
$appId, null, $channelName, (object) $payload
86+
$channel->broadcastLocally(
87+
$appId, (object) $payload, true
9488
);
9589
}
90+
91+
$channelManager->broadcastAcrossServers(
92+
$appId, null, $channelName, (object) $payload
93+
);
9694
}
9795
}

0 commit comments

Comments
 (0)