Passing the Socket ID to the broadcastAcrossServers()
This commit is contained in:
parent
0f90f521e0
commit
30c6635a91
|
|
@ -45,7 +45,7 @@ class TriggerEvent extends Controller
|
|||
);
|
||||
} else {
|
||||
$this->channelManager->broadcastAcrossServers(
|
||||
$request->appId, $channelName, (object) $payload
|
||||
$request->appId, $request->socket_id, $channelName, (object) $payload
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -259,11 +259,13 @@ class LocalChannelManager implements ChannelManager
|
|||
* Broadcast the message across multiple servers.
|
||||
*
|
||||
* @param string|int $appId
|
||||
* @param string|null $socketId
|
||||
* @param string $channel
|
||||
* @param stdClass $payload
|
||||
* @param string|null $serverId
|
||||
* @return bool
|
||||
*/
|
||||
public function broadcastAcrossServers($appId, string $channel, stdClass $payload)
|
||||
public function broadcastAcrossServers($appId, ?string $socketId, string $channel, stdClass $payload, string $serverId = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,14 +268,17 @@ class RedisChannelManager extends LocalChannelManager
|
|||
* Broadcast the message across multiple servers.
|
||||
*
|
||||
* @param string|int $appId
|
||||
* @param string|null $socketId
|
||||
* @param string $channel
|
||||
* @param stdClass $payload
|
||||
* @param string|null $serverId
|
||||
* @return bool
|
||||
*/
|
||||
public function broadcastAcrossServers($appId, string $channel, stdClass $payload)
|
||||
public function broadcastAcrossServers($appId, ?string $socketId, string $channel, stdClass $payload, string $serverId = null)
|
||||
{
|
||||
$payload->appId = $appId;
|
||||
$payload->serverId = $this->getServerId();
|
||||
$payload->socketId = $socketId;
|
||||
$payload->serverId = $serverId ?: $this->getServerId();
|
||||
|
||||
$this->publishClient->publish($this->getRedisKey($appId, $channel), json_encode($payload));
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class Channel
|
|||
->each->send(json_encode($payload));
|
||||
|
||||
if ($replicate) {
|
||||
$this->channelManager->broadcastAcrossServers($appId, $this->getName(), $payload);
|
||||
$this->channelManager->broadcastAcrossServers($appId, null, $this->getName(), $payload);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -148,7 +148,7 @@ class Channel
|
|||
public function broadcastToEveryoneExcept(stdClass $payload, ?string $socketId, $appId, bool $replicate = true)
|
||||
{
|
||||
if ($replicate) {
|
||||
$this->channelManager->broadcastAcrossServers($appId, $this->getName(), $payload);
|
||||
$this->channelManager->broadcastAcrossServers($appId, $socketId, $this->getName(), $payload);
|
||||
}
|
||||
|
||||
if (is_null($socketId)) {
|
||||
|
|
|
|||
|
|
@ -131,11 +131,13 @@ interface ChannelManager
|
|||
* Broadcast the message across multiple servers.
|
||||
*
|
||||
* @param string|int $appId
|
||||
* @param string|null $socketId
|
||||
* @param string $channel
|
||||
* @param stdClass $payload
|
||||
* @param string|null $serverId
|
||||
* @return bool
|
||||
*/
|
||||
public function broadcastAcrossServers($appId, string $channel, stdClass $payload);
|
||||
public function broadcastAcrossServers($appId, ?string $socketId, string $channel, stdClass $payload, string $serverId = null);
|
||||
|
||||
/**
|
||||
* Handle the user when it joined a presence channel.
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class DashboardLogger
|
|||
);
|
||||
} else {
|
||||
$channelManager->broadcastAcrossServers(
|
||||
$appId, $channelName, (object) $payload
|
||||
$appId, null, $channelName, (object) $payload
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue