diff --git a/src/Protocols/Pusher/EventDispatcher.php b/src/Protocols/Pusher/EventDispatcher.php index fe5830a..c4e8f22 100644 --- a/src/Protocols/Pusher/EventDispatcher.php +++ b/src/Protocols/Pusher/EventDispatcher.php @@ -24,12 +24,17 @@ public static function dispatch(Application $app, array $payload, ?Connection $c return; } - app(PubSubProvider::class)->publish([ + $data = [ 'type' => 'message', 'application' => serialize($app), 'payload' => $payload, - 'socket_id' => $connection?->id(), - ]); + ]; + + if ($connection?->id() !== null) { + $data['socket_id'] = $connection?->id(); + } + + app(PubSubProvider::class)->publish($data); } /**