Skip to content

Commit

Permalink
Bugfix for PR 275 - omit socket-id if null (#280)
Browse files Browse the repository at this point in the history
* Omit the socket_id key from the payload, unless a socket_id exists

* Update EventDispatcher.php

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
larswolff and taylorotwell authored Dec 6, 2024
1 parent 87ae4fd commit 22eab51
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Protocols/Pusher/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 22eab51

Please sign in to comment.