Enforce topic subscription

This commit is contained in:
Alex Renoki 2020-09-17 10:51:01 +03:00
parent 40f024d031
commit b7ba98a6a6
1 changed files with 4 additions and 9 deletions

View File

@ -158,12 +158,7 @@ class RedisChannelManager extends LocalChannelManager
*/ */
public function subscribeToChannel(ConnectionInterface $connection, string $channelName, stdClass $payload) public function subscribeToChannel(ConnectionInterface $connection, string $channelName, stdClass $payload)
{ {
$this->getGlobalConnectionsCount($connection->app->id, $channelName)
->then(function ($count) use ($connection, $channelName) {
if ($count === 0) {
$this->subscribeToTopic($connection->app->id, $channelName); $this->subscribeToTopic($connection->app->id, $channelName);
}
});
$this->addConnectionToSet($connection); $this->addConnectionToSet($connection);
@ -753,13 +748,13 @@ class RedisChannelManager extends LocalChannelManager
$hash = "{$prefix}{$appId}"; $hash = "{$prefix}{$appId}";
if ($channel) { if ($channel) {
$hash .= ":{$channel}"; $suffixes = array_merge([$channel], $suffixes);
} }
$suffixes = join(':', $suffixes); $suffixes = implode(':', $suffixes);
if ($suffixes) { if ($suffixes) {
$hash .= $suffixes; $hash .= ":{$suffixes}";
} }
return $hash; return $hash;