Skip to content

Commit 6699c26

Browse files
committed
Make sure we only subscribe to a channel once
1 parent a682d92 commit 6699c26

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/AsyncClient.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public function __construct(LoopInterface $loop, string $app, Transport $transpo
5656

5757
public function channel(string $channel): ObservableInterface
5858
{
59+
if (isset($this->channels[$channel])) {
60+
return $this->channels[$channel];
61+
}
62+
5963
$channelMessages = $this->messages->filter(function ($event) use ($channel) {
6064
return isset($event->channel) && $event->channel == $channel;
6165
});
@@ -82,7 +86,8 @@ public function channel(string $channel): ObservableInterface
8286
});
8387
});
8488

85-
return $events->share();
89+
$this->channels[$channel] = $events->share();
90+
return $this->channels[$channel];
8691
}
8792

8893
public function send(array $message)

0 commit comments

Comments
 (0)