Skip to content

Commit

Permalink
Fix for issue #246
Browse files Browse the repository at this point in the history
Pass SocketID through redis, and filter it on the receiving end.

This ensures that ->toOthers() works with scaling = true
  • Loading branch information
larswolff committed Nov 26, 2024
1 parent 05ec48d commit ae2e9fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Protocols/Pusher/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static function dispatch(Application $app, array $payload, ?Connection $c
'type' => 'message',
'application' => serialize($app),
'payload' => $payload,
'socket_id' => $connection?->id(),
]);
}

Expand All @@ -46,7 +47,6 @@ public static function dispatchSynchronously(Application $app, array $payload, ?
}

$payload['channel'] = $channel->name();

$channel->broadcast($payload, $connection);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/Protocols/Pusher/PusherPubSubIncomingMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ public function handle(string $payload): void

$application = unserialize($event['application']);

$except = isset($event['socket_id']) ?
app(ChannelManager::class)->for($application)->connections()[$event['socket_id']] ?? null
: null;

match ($event['type'] ?? null) {
'message' => EventDispatcher::dispatchSynchronously(
$application,
$event['payload']
$event['payload'],
$except?->connection()
),
'metrics' => app(MetricsHandler::class)->publish(
$application,
Expand Down

0 comments on commit ae2e9fe

Please sign in to comment.