Attempt at making TriggerEventController also publish to other servers
This commit is contained in:
parent
091f56ea15
commit
ef86f86668
|
|
@ -117,7 +117,7 @@ class RedisClient implements ReplicationInterface
|
||||||
unset($payload->appId);
|
unset($payload->appId);
|
||||||
|
|
||||||
// Push the message out to connected websocket clients
|
// Push the message out to connected websocket clients
|
||||||
$channel->broadcastToEveryoneExcept($payload, $socket);
|
$channel->broadcastToEveryoneExcept($payload, $socket, $appId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -110,14 +110,19 @@ class Channel
|
||||||
|
|
||||||
public function broadcastToOthers(ConnectionInterface $connection, $payload)
|
public function broadcastToOthers(ConnectionInterface $connection, $payload)
|
||||||
{
|
{
|
||||||
// Also broadcast via the other websocket servers
|
$this->broadcastToEveryoneExcept($payload, $connection->socketId, $connection->app->id);
|
||||||
$this->replication->publish($connection->app->id, $this->channelName, $payload);
|
|
||||||
|
|
||||||
$this->broadcastToEveryoneExcept($payload, $connection->socketId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function broadcastToEveryoneExcept($payload, ?string $socketId = null)
|
public function broadcastToEveryoneExcept($payload, ?string $socketId, string $appId, bool $publish = true)
|
||||||
{
|
{
|
||||||
|
// Also broadcast via the other websocket server instances.
|
||||||
|
// This is set false in the Redis client because we don't want to cause a loop
|
||||||
|
// in this case. If this came from TriggerEventController, then we still want
|
||||||
|
// to publish to get the message out to other server instances.
|
||||||
|
if ($publish) {
|
||||||
|
$this->replication->publish($appId, $this->channelName, $payload);
|
||||||
|
}
|
||||||
|
|
||||||
// Performance optimization, if we don't have a socket ID,
|
// Performance optimization, if we don't have a socket ID,
|
||||||
// then we avoid running the if condition in the foreach loop below
|
// then we avoid running the if condition in the foreach loop below
|
||||||
// by calling broadcast() instead.
|
// by calling broadcast() instead.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue