wip
This commit is contained in:
parent
b698b95147
commit
f9d44040eb
|
|
@ -23,11 +23,11 @@ class TriggerEvent extends EchoController
|
||||||
foreach ($request->json()->get('channels', []) as $channelId) {
|
foreach ($request->json()->get('channels', []) as $channelId) {
|
||||||
$channel = $this->channelManager->find($request->appId, $channelId);
|
$channel = $this->channelManager->find($request->appId, $channelId);
|
||||||
|
|
||||||
optional($channel)->broadcast([
|
optional($channel)->broadcastToEveryoneExcept([
|
||||||
'channel' => $channelId,
|
'channel' => $channelId,
|
||||||
'event' => $request->json()->get('name'),
|
'event' => $request->json()->get('name'),
|
||||||
'data' => $request->json()->get('data'),
|
'data' => $request->json()->get('data'),
|
||||||
]);
|
], $request->json()->get('socket_id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $request->json()->all();
|
return $request->json()->all();
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,16 @@ class Channel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function broadcastToEveryoneExcept($payload, ?string $socketId = null)
|
||||||
|
{
|
||||||
|
Collection::make($this->subscriptions)->reject(function ($existingConnection) use ($socketId) {
|
||||||
|
return $existingConnection->socketId === $socketId;
|
||||||
|
})->each->send(json_encode($payload));
|
||||||
|
}
|
||||||
|
|
||||||
public function broadcastToOthers(ConnectionInterface $connection, $payload)
|
public function broadcastToOthers(ConnectionInterface $connection, $payload)
|
||||||
{
|
{
|
||||||
Collection::make($this->subscriptions)->reject(function ($existingConnection) use ($connection) {
|
$this->broadcastToEveryoneExcept($payload, $connection->socketId);
|
||||||
return $existingConnection->socketId === $connection->socketId;
|
|
||||||
})->each->send(json_encode($payload));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue