Skip to content

Commit f8794f4

Browse files
committed
Added some more notes to the async client
1 parent 78e21c6 commit f8794f4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/AsyncClient.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public function __construct(Observable $client)
107107
));
108108
}
109109

110+
// If this event represents the connection_established event set the timeout
110111
if ($event->getEvent() === 'pusher:connection_established') {
111112
$this->setActivityTimeout($event);
112113
}
@@ -167,6 +168,7 @@ public static function create(LoopInterface $loop, string $app, Resolver $resolv
167168
*/
168169
public function channel(string $channel): Observable
169170
{
171+
// Only join a channel once
170172
if (isset($this->channels[$channel])) {
171173
return $this->channels[$channel];
172174
}
@@ -176,12 +178,14 @@ public function channel(string $channel): Observable
176178
return $event->getChannel() !== '' && $event->getChannel() === $channel;
177179
});
178180

181+
// Observable representing channel events
179182
$events = Observable::create(function (
180183
ObserverInterface $observer
181184
) use (
182185
$channel,
183186
$channelMessages
184187
) {
188+
// Subscribe to channel messages but filter out internal events
185189
$subscription = $channelMessages
186190
->filter(function (Event $event) {
187191
return $event->getEvent() !== 'pusher_internal:subscription_succeeded';
@@ -231,6 +235,7 @@ public function send(array $message): bool
231235
*/
232236
private function handleLowLevelError(Throwable $throwable)
233237
{
238+
// Only allow certain, relevant, exceptions
234239
if (!($throwable instanceof WebsocketErrorException) &&
235240
!($throwable instanceof RuntimeException) &&
236241
!($throwable instanceof PusherErrorException)

0 commit comments

Comments
 (0)