From 27126b348dcafd6bdc34593b8699d3a8699d5f73 Mon Sep 17 00:00:00 2001 From: Mohammad Reza Ansary Date: Wed, 11 Aug 2021 13:09:09 +0430 Subject: [PATCH 1/2] Remove debug form of socket options --- Sources/SocketKit/Socket/Options.swift | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Sources/SocketKit/Socket/Options.swift b/Sources/SocketKit/Socket/Options.swift index 59e3a49..0739c79 100644 --- a/Sources/SocketKit/Socket/Options.swift +++ b/Sources/SocketKit/Socket/Options.swift @@ -19,16 +19,6 @@ public protocol Options { var activityTimeout: TimeInterval? { get } } -extension Options { - public var authMethod: AuthMethod { - #if DEBUG - return .inline(secret: "6cbdbeb15886107d0a0e") - #else - return .inline(secret: "") - #endif - } -} - extension PusherClientOptions: Options { } extension Options { From 6f167ace5705fa1008a20547e879caa1c545010f Mon Sep 17 00:00:00 2001 From: Mohammad Reza Ansary Date: Wed, 11 Aug 2021 13:10:42 +0430 Subject: [PATCH 2/2] Fix bug of subscribing on channels --- Sources/SocketKit/Socket/Socket.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Sources/SocketKit/Socket/Socket.swift b/Sources/SocketKit/Socket/Socket.swift index f435a16..5a3722d 100644 --- a/Sources/SocketKit/Socket/Socket.swift +++ b/Sources/SocketKit/Socket/Socket.swift @@ -49,7 +49,7 @@ extension Socket: SocketManager { } public func subscribe(_ name: String) throws { - guard pusher.connection.channels.channels.contains(where: { $0.key != name }) else { + guard !pusher.connection.channels.channels.contains(where: { $0.key == name }) else { throw(SocketError.channelExist) } _ = pusher.subscribe(name) @@ -81,15 +81,13 @@ extension Socket { } catch let error { handler(.failure(error as! SocketError)) } - return } - channel.value.bind(eventName: event) { event in guard let json: String = event.data, let jsonData: Data = json.data(using: .utf8) else { - print("Could not convert JSON string to data") + assertionFailure("ForDebug: Could not convert JSON string to data") return }