From 5b45899c54867b1633612e059bcb4437d1caafb3 Mon Sep 17 00:00:00 2001 From: George Chailazopoulos Date: Mon, 15 Nov 2021 17:03:04 +0200 Subject: [PATCH 1/4] Nullify _pusherInstance on disconnect This is needed in order to be able to reset the pusher instance connection in case for example the auth token changes. --- .../com/github/chinloyal/pusher_client/pusher/PusherService.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/com/github/chinloyal/pusher_client/pusher/PusherService.kt b/android/src/main/kotlin/com/github/chinloyal/pusher_client/pusher/PusherService.kt index 5fea015..0414af1 100644 --- a/android/src/main/kotlin/com/github/chinloyal/pusher_client/pusher/PusherService.kt +++ b/android/src/main/kotlin/com/github/chinloyal/pusher_client/pusher/PusherService.kt @@ -127,6 +127,7 @@ class PusherService : MChannel { private fun disconnect(result: Result) { _pusherInstance?.disconnect() debugLog("Disconnect") + _pusherInstance = null result.success(null) } @@ -293,4 +294,4 @@ class PusherService : MChannel { } } -} \ No newline at end of file +} From 50862b5f7a89874c4bc1e41fd7b3fc6f9b7a25fd Mon Sep 17 00:00:00 2001 From: George Chailazopoulos Date: Mon, 15 Nov 2021 17:05:54 +0200 Subject: [PATCH 2/4] Update PusherService.swift --- ios/Classes/PusherService.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/ios/Classes/PusherService.swift b/ios/Classes/PusherService.swift index 9dcce74..1bbe654 100644 --- a/ios/Classes/PusherService.swift +++ b/ios/Classes/PusherService.swift @@ -107,6 +107,7 @@ class PusherService: MChannel { func disconnect(result:@escaping FlutterResult) { _pusherInstance.disconnect() Utils.debugLog(msg: "Disconnect") + _pusherInstance = nil result(nil) } From aaf3d8d5cc139a2a2bf0fc6682af6536f6bf81b3 Mon Sep 17 00:00:00 2001 From: George Chailazopoulos Date: Mon, 15 Nov 2021 17:57:07 +0200 Subject: [PATCH 3/4] Update PusherService.kt --- .../com/github/chinloyal/pusher_client/pusher/PusherService.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/android/src/main/kotlin/com/github/chinloyal/pusher_client/pusher/PusherService.kt b/android/src/main/kotlin/com/github/chinloyal/pusher_client/pusher/PusherService.kt index 0414af1..b3c6282 100644 --- a/android/src/main/kotlin/com/github/chinloyal/pusher_client/pusher/PusherService.kt +++ b/android/src/main/kotlin/com/github/chinloyal/pusher_client/pusher/PusherService.kt @@ -80,7 +80,6 @@ class PusherService : MChannel { val initArgs: JSONObject = args.getJSONObject("initArgs") enableLogging = initArgs.getBoolean("enableLogging") - if(_pusherInstance == null) { val options: JSONObject = args.getJSONObject("pusherOptions") val pusherOptions = PusherOptions() @@ -114,7 +113,6 @@ class PusherService : MChannel { _pusherInstance = Pusher(args.getString("appKey"), pusherOptions) debugLog("Pusher initialized") - } result.success(null) } @@ -127,7 +125,6 @@ class PusherService : MChannel { private fun disconnect(result: Result) { _pusherInstance?.disconnect() debugLog("Disconnect") - _pusherInstance = null result.success(null) } From 93eaedd9903df848005528aa89c4f4ff787e2507 Mon Sep 17 00:00:00 2001 From: George Chailazopoulos Date: Mon, 15 Nov 2021 17:57:48 +0200 Subject: [PATCH 4/4] Update PusherService.swift --- ios/Classes/PusherService.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/ios/Classes/PusherService.swift b/ios/Classes/PusherService.swift index 1bbe654..2d5b9b0 100644 --- a/ios/Classes/PusherService.swift +++ b/ios/Classes/PusherService.swift @@ -73,7 +73,6 @@ class PusherService: MChannel { Utils.enableLogging = pusherArgs.initArgs.enableLogging - if(_pusherInstance == nil) { let pusherOptions = PusherClientOptions( authMethod: pusherArgs.pusherOptions.auth == nil ? .noMethod : AuthMethod.authRequestBuilder(authRequestBuilder: AuthRequestBuilder(pusherAuth: pusherArgs.pusherOptions.auth!)), host: pusherArgs.pusherOptions.cluster != nil ? .cluster(pusherArgs.pusherOptions.cluster!) : .host(pusherArgs.pusherOptions.host), @@ -91,7 +90,6 @@ class PusherService: MChannel { Utils.debugLog(msg: "Pusher initialized") result(nil) - } } catch let err { Utils.errorLog(msg: err.localizedDescription) result(FlutterError(code: "INIT_ERROR", message: err.localizedDescription, details: err)) @@ -107,7 +105,6 @@ class PusherService: MChannel { func disconnect(result:@escaping FlutterResult) { _pusherInstance.disconnect() Utils.debugLog(msg: "Disconnect") - _pusherInstance = nil result(nil) }