Skip to content

Commit

Permalink
Added some more notes to the async client
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed May 24, 2017
1 parent 78e21c6 commit f8794f4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/AsyncClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public function __construct(Observable $client)
));
}

// If this event represents the connection_established event set the timeout
if ($event->getEvent() === 'pusher:connection_established') {
$this->setActivityTimeout($event);
}
Expand Down Expand Up @@ -167,6 +168,7 @@ public static function create(LoopInterface $loop, string $app, Resolver $resolv
*/
public function channel(string $channel): Observable
{
// Only join a channel once
if (isset($this->channels[$channel])) {
return $this->channels[$channel];
}
Expand All @@ -176,12 +178,14 @@ public function channel(string $channel): Observable
return $event->getChannel() !== '' && $event->getChannel() === $channel;
});

// Observable representing channel events
$events = Observable::create(function (
ObserverInterface $observer
) use (
$channel,
$channelMessages
) {
// Subscribe to channel messages but filter out internal events
$subscription = $channelMessages
->filter(function (Event $event) {
return $event->getEvent() !== 'pusher_internal:subscription_succeeded';
Expand Down Expand Up @@ -231,6 +235,7 @@ public function send(array $message): bool
*/
private function handleLowLevelError(Throwable $throwable)
{
// Only allow certain, relevant, exceptions
if (!($throwable instanceof WebsocketErrorException) &&
!($throwable instanceof RuntimeException) &&
!($throwable instanceof PusherErrorException)
Expand Down

0 comments on commit f8794f4

Please sign in to comment.