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

Commit 1616321

Browse files
committed
Fixed double broadcasting.
1 parent b39b33c commit 1616321

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/HttpApi/Controllers/TriggerEventController.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ public function __invoke(Request $request)
2929
'data' => $request->data,
3030
];
3131

32-
optional($channel)->broadcastToEveryoneExcept($payload, $request->socket_id, $request->appId);
33-
34-
// If the setup is horizontally-scaled using the Redis Pub/Sub,
35-
// then we're going to make sure it gets streamed to the other
36-
// servers as well that are subscribed to the Pub/Sub topics
37-
// attached to the current iterated app & channel.
38-
// For local setups, the local driver will ignore the publishes.
39-
40-
$this->replicator->publish($request->appId, $channelName, $payload);
32+
if ($channel) {
33+
$channel->broadcastToEveryoneExcept(
34+
$payload, $request->socket_id, $request->appId
35+
);
36+
} else {
37+
// If the setup is horizontally-scaled using the Redis Pub/Sub,
38+
// then we're going to make sure it gets streamed to the other
39+
// servers as well that are subscribed to the Pub/Sub topics
40+
// attached to the current iterated app & channel.
41+
// For local setups, the local driver will ignore the publishes.
42+
43+
$this->replicator->publish($request->appId, $channelName, $payload);
44+
}
4145

4246
DashboardLogger::log($request->appId, DashboardLogger::TYPE_API_MESSAGE, [
4347
'channel' => $channelName,

0 commit comments

Comments
 (0)