From 7d50099137592f540fa9d5733ddc604949c316e0 Mon Sep 17 00:00:00 2001 From: Vladimir Petrov Date: Fri, 14 Oct 2022 12:11:44 +0400 Subject: [PATCH] Fixed channel identifier check for type ping --- Sources/ActionCableSwift/ACChannel.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/ActionCableSwift/ACChannel.swift b/Sources/ActionCableSwift/ACChannel.swift index 8ddf25c..2bd5acb 100644 --- a/Sources/ActionCableSwift/ACChannel.swift +++ b/Sources/ActionCableSwift/ACChannel.swift @@ -170,21 +170,21 @@ public class ACChannel { guard let self = self else { return } self.channelSerialQueue.async { let message = ACSerializer.responseFrom(stringData: text) - guard message.channelName == self.channelName else { return } - switch message.type { - case .confirmSubscription: + let sameChannelName = message.channelName == self.channelName + switch (message.type, sameChannelName) { + case (.confirmSubscription, true): self.isSubscribed = true self.executeCallback(callbacks: self.onSubscribe, message: message) self.flushBuffer() - case .rejectSubscription: + case (.rejectSubscription, true): self.isSubscribed = false self.executeCallback(callbacks: self.onRejectSubscription, message: message) - case .cancelSubscription: + case (.cancelSubscription, true): self.isSubscribed = false self.executeCallback(callbacks: self.onUnsubscribe, message: message) - case .message: + case (.message, true): self.executeCallback(callbacks: self.onMessage, message: message) - case .ping: + case (.ping, _): self.client?.pingRoundWatcher.ping() self.executeCallback(callbacks: self.onPing) default: break