Skip to content

Commit 22eab51

Browse files
Bugfix for PR 275 - omit socket-id if null (#280)
* Omit the socket_id key from the payload, unless a socket_id exists * Update EventDispatcher.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 87ae4fd commit 22eab51

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Protocols/Pusher/EventDispatcher.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ public static function dispatch(Application $app, array $payload, ?Connection $c
2424
return;
2525
}
2626

27-
app(PubSubProvider::class)->publish([
27+
$data = [
2828
'type' => 'message',
2929
'application' => serialize($app),
3030
'payload' => $payload,
31-
'socket_id' => $connection?->id(),
32-
]);
31+
];
32+
33+
if ($connection?->id() !== null) {
34+
$data['socket_id'] = $connection?->id();
35+
}
36+
37+
app(PubSubProvider::class)->publish($data);
3338
}
3439

3540
/**

0 commit comments

Comments
 (0)