From fb0649f3b46325f5156a7ff0c1e7bc643af18df1 Mon Sep 17 00:00:00 2001 From: Pandu Masabathula Date: Mon, 8 Aug 2022 18:55:52 +0530 Subject: [PATCH 1/4] Fix for listeners when destroy is called --- src/Api/PubnubApi/PubnubCoreBase.cs | 11 +++++++++-- .../PubnubApi.ConsoleExample.csproj | 4 ++-- src/Examples/PubnubApi.ConsoleExample/packages.config | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Api/PubnubApi/PubnubCoreBase.cs b/src/Api/PubnubApi/PubnubCoreBase.cs index de7465e0a..8f9a50adf 100644 --- a/src/Api/PubnubApi/PubnubCoreBase.cs +++ b/src/Api/PubnubApi/PubnubCoreBase.cs @@ -2273,7 +2273,10 @@ protected bool DeleteLocalChannelGroupUserState(string channelGroup) internal void EndPendingRequests() { - SubscribeCallbackListenerList.Clear(); + if (SubscribeCallbackListenerList.ContainsKey(PubnubInstance.InstanceId)) + { + SubscribeCallbackListenerList[PubnubInstance.InstanceId].Clear(); + } RemoveChannelDictionary(); TerminatePendingWebRequest(); @@ -2314,7 +2317,11 @@ internal void EndPendingRequests() ChannelGroupUserState[PubnubInstance.InstanceId].Clear(); } - RemoveHttpClients(); + if (MultiChannelSubscribe.Count > 0 && MultiChannelSubscribe.Select(t => t.Value.Count > 0).Count() == 0 + && MultiChannelGroupSubscribe.Count > 0 && MultiChannelGroupSubscribe.Select(t => t.Value.Count > 0).Count() == 0) + { + RemoveHttpClients(); + } PubnubInstance = null; } diff --git a/src/Examples/PubnubApi.ConsoleExample/PubnubApi.ConsoleExample.csproj b/src/Examples/PubnubApi.ConsoleExample/PubnubApi.ConsoleExample.csproj index b6ff129ec..a41ae4303 100644 --- a/src/Examples/PubnubApi.ConsoleExample/PubnubApi.ConsoleExample.csproj +++ b/src/Examples/PubnubApi.ConsoleExample/PubnubApi.ConsoleExample.csproj @@ -48,8 +48,8 @@ ..\..\packages\PeterO.Numbers.1.8.2\lib\net40\Numbers.dll - - ..\..\packages\Pubnub.6.6.0\lib\net48\Pubnub.dll + + ..\..\packages\Pubnub.6.7.0\lib\net48\Pubnub.dll diff --git a/src/Examples/PubnubApi.ConsoleExample/packages.config b/src/Examples/PubnubApi.ConsoleExample/packages.config index ce9efe1e5..795c57286 100644 --- a/src/Examples/PubnubApi.ConsoleExample/packages.config +++ b/src/Examples/PubnubApi.ConsoleExample/packages.config @@ -4,7 +4,7 @@ - + From ef49792f7e2c597ea32d70fa12de39235fb314e6 Mon Sep 17 00:00:00 2001 From: Pandu Masabathula Date: Mon, 8 Aug 2022 23:54:51 +0530 Subject: [PATCH 2/4] removed RemoveHttpClients --- src/Api/PubnubApi/PubnubCoreBase.cs | 40 ----------------------------- 1 file changed, 40 deletions(-) diff --git a/src/Api/PubnubApi/PubnubCoreBase.cs b/src/Api/PubnubApi/PubnubCoreBase.cs index 8f9a50adf..e1e4451c4 100644 --- a/src/Api/PubnubApi/PubnubCoreBase.cs +++ b/src/Api/PubnubApi/PubnubCoreBase.cs @@ -2317,49 +2317,9 @@ internal void EndPendingRequests() ChannelGroupUserState[PubnubInstance.InstanceId].Clear(); } - if (MultiChannelSubscribe.Count > 0 && MultiChannelSubscribe.Select(t => t.Value.Count > 0).Count() == 0 - && MultiChannelGroupSubscribe.Count > 0 && MultiChannelGroupSubscribe.Select(t => t.Value.Count > 0).Count() == 0) - { - RemoveHttpClients(); - } - PubnubInstance = null; } - internal static void RemoveHttpClients() - { - //Conditionalmethod logic -#if !NET35 && !NET40 && !NET45 && !NET461 && !NET48 && !NETSTANDARD10 - if (httpClientNetworkStatus != null) - { - try{ - httpClientNetworkStatus.CancelPendingRequests(); - httpClientNetworkStatus.Dispose(); - httpClientNetworkStatus = null; - } - catch { /* ignore */ } - } - if (httpClientSubscribe != null) - { - try{ - httpClientSubscribe.CancelPendingRequests(); - httpClientSubscribe.Dispose(); - httpClientSubscribe = null; - } - catch { /* ignore */ } - } - if (httpClientNonsubscribe != null) - { - try{ - httpClientNonsubscribe.CancelPendingRequests(); - httpClientNonsubscribe.Dispose(); - httpClientNonsubscribe = null; - } - catch { /* ignore */ } - } -#endif - } - internal void TerminateCurrentSubscriberRequest() { string[] channels = GetCurrentSubscriberChannels(); From e47a40af1d09646f78732c5d6863695815b481a0 Mon Sep 17 00:00:00 2001 From: Pandu Masabathula Date: Tue, 9 Aug 2022 16:02:03 +0530 Subject: [PATCH 3/4] RemoveHttpClients condition --- src/Api/PubnubApi/PubnubCoreBase.cs | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/Api/PubnubApi/PubnubCoreBase.cs b/src/Api/PubnubApi/PubnubCoreBase.cs index e1e4451c4..7ce2c9841 100644 --- a/src/Api/PubnubApi/PubnubCoreBase.cs +++ b/src/Api/PubnubApi/PubnubCoreBase.cs @@ -2317,9 +2317,48 @@ internal void EndPendingRequests() ChannelGroupUserState[PubnubInstance.InstanceId].Clear(); } + if (MultiChannelSubscribe.Count > 0 && MultiChannelSubscribe.Where(t => t.Value.Keys.Count > 0).Count() == 0 + && MultiChannelGroupSubscribe.Count > 0 && MultiChannelGroupSubscribe.Where(t => t.Value.Keys.Count > 0).Count() == 0) + { + RemoveHttpClients(); + } PubnubInstance = null; } + internal static void RemoveHttpClients() + { + //Conditionalmethod logic +#if !NET35 && !NET40 && !NET45 && !NET461 && !NET48 && !NETSTANDARD10 + if (httpClientNetworkStatus != null) + { + try{ + httpClientNetworkStatus.CancelPendingRequests(); + httpClientNetworkStatus.Dispose(); + httpClientNetworkStatus = null; + } + catch { /* ignore */ } + } + if (httpClientSubscribe != null) + { + try{ + httpClientSubscribe.CancelPendingRequests(); + httpClientSubscribe.Dispose(); + httpClientSubscribe = null; + } + catch { /* ignore */ } + } + if (httpClientNonsubscribe != null) + { + try{ + httpClientNonsubscribe.CancelPendingRequests(); + httpClientNonsubscribe.Dispose(); + httpClientNonsubscribe = null; + } + catch { /* ignore */ } + } +#endif + } + internal void TerminateCurrentSubscriberRequest() { string[] channels = GetCurrentSubscriberChannels(); From 7164964929b0e8ccb909623d2e04b9bfb042d78d Mon Sep 17 00:00:00 2001 From: Client Engineering Bot <60980775+client-engineering-bot@users.noreply.github.com> Date: Wed, 10 Aug 2022 16:46:44 +0000 Subject: [PATCH 4/4] PubNub SDK v6.8.0.0 release. --- .pubnub.yml | 19 ++++++++++++------- CHANGELOG | 4 ++++ src/Api/PubnubApi/Properties/AssemblyInfo.cs | 4 ++-- src/Api/PubnubApi/PubnubApi.csproj | 4 ++-- src/Api/PubnubApiPCL/PubnubApiPCL.csproj | 4 ++-- src/Api/PubnubApiUWP/PubnubApiUWP.csproj | 4 ++-- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index 0bba21805..02fdc5510 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,8 +1,13 @@ name: c-sharp -version: "6.7.0" +version: "6.8.0" schema: 1 scm: github.com/pubnub/c-sharp changelog: + - date: 2022-08-10 + version: v6.8.0 + changes: + - type: bug + text: "Fixed Destroy() method when multiple Pubnub instances were in use." - date: 2022-07-27 version: v6.7.0 changes: @@ -665,7 +670,7 @@ features: - QUERY-PARAM supported-platforms: - - version: Pubnub 'C#' 6.7.0 + version: Pubnub 'C#' 6.8.0 platforms: - Windows 10 and up - Windows Server 2008 and up @@ -675,7 +680,7 @@ supported-platforms: - .Net Framework 4.5 - .Net Framework 4.6.1+ - - version: PubnubPCL 'C#' 6.7.0 + version: PubnubPCL 'C#' 6.8.0 platforms: - Xamarin.Android - Xamarin.iOS @@ -695,7 +700,7 @@ supported-platforms: - .Net Core - .Net 6.0 - - version: PubnubUWP 'C#' 6.7.0 + version: PubnubUWP 'C#' 6.8.0 platforms: - Windows Phone 10 - Universal Windows Apps @@ -719,7 +724,7 @@ sdks: distribution-type: source distribution-repository: GitHub package-name: Pubnub - location: https://github.com/pubnub/c-sharp/releases/tag/v6.7.0.0 + location: https://github.com/pubnub/c-sharp/releases/tag/v6.8.0.0 requires: - name: ".Net" @@ -1002,7 +1007,7 @@ sdks: distribution-type: source distribution-repository: GitHub package-name: PubNubPCL - location: https://github.com/pubnub/c-sharp/releases/tag/v6.7.0.0 + location: https://github.com/pubnub/c-sharp/releases/tag/v6.8.0.0 requires: - name: ".Net Core" @@ -1361,7 +1366,7 @@ sdks: distribution-type: source distribution-repository: GitHub package-name: PubnubUWP - location: https://github.com/pubnub/c-sharp/releases/tag/v6.7.0.0 + location: https://github.com/pubnub/c-sharp/releases/tag/v6.8.0.0 requires: - name: "Universal Windows Platform Development" diff --git a/CHANGELOG b/CHANGELOG index 4d6f6fcf5..3747e8fb3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +v6.8.0 - August 10 2022 +----------------------------- +- Fixed: fixed Destroy() method when multiple Pubnub instances were in use. + v6.7.0 - July 27 2022 ----------------------------- - Modified: added support for Users/Spaces to GrantToken. diff --git a/src/Api/PubnubApi/Properties/AssemblyInfo.cs b/src/Api/PubnubApi/Properties/AssemblyInfo.cs index 6fd67cfe4..a35e09a23 100644 --- a/src/Api/PubnubApi/Properties/AssemblyInfo.cs +++ b/src/Api/PubnubApi/Properties/AssemblyInfo.cs @@ -11,8 +11,8 @@ [assembly: AssemblyProduct("Pubnub C# SDK")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("6.7.0.0")] -[assembly: AssemblyFileVersion("6.7.0.0")] +[assembly: AssemblyVersion("6.8.0.0")] +[assembly: AssemblyFileVersion("6.8.0.0")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. diff --git a/src/Api/PubnubApi/PubnubApi.csproj b/src/Api/PubnubApi/PubnubApi.csproj index cf2ce9670..0a5506e93 100644 --- a/src/Api/PubnubApi/PubnubApi.csproj +++ b/src/Api/PubnubApi/PubnubApi.csproj @@ -13,7 +13,7 @@ Pubnub - 6.7.0.0 + 6.8.0.0 PubNub C# .NET - Web Data Push API Pandu Masabathula PubNub @@ -21,7 +21,7 @@ http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png true https://github.com/pubnub/c-sharp/ - Added support for Users/Spaces to GrantToken. + Fixed Destroy() method when multiple Pubnub instances were in use. Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously diff --git a/src/Api/PubnubApiPCL/PubnubApiPCL.csproj b/src/Api/PubnubApiPCL/PubnubApiPCL.csproj index c17393579..47083a067 100644 --- a/src/Api/PubnubApiPCL/PubnubApiPCL.csproj +++ b/src/Api/PubnubApiPCL/PubnubApiPCL.csproj @@ -14,7 +14,7 @@ PubnubPCL - 6.7.0.0 + 6.8.0.0 PubNub C# .NET - Web Data Push API Pandu Masabathula PubNub @@ -22,7 +22,7 @@ http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png true https://github.com/pubnub/c-sharp/ - Added support for Users/Spaces to GrantToken. + Fixed Destroy() method when multiple Pubnub instances were in use. Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously diff --git a/src/Api/PubnubApiUWP/PubnubApiUWP.csproj b/src/Api/PubnubApiUWP/PubnubApiUWP.csproj index 3b8460a23..dfb7075f5 100644 --- a/src/Api/PubnubApiUWP/PubnubApiUWP.csproj +++ b/src/Api/PubnubApiUWP/PubnubApiUWP.csproj @@ -15,7 +15,7 @@ PubnubUWP - 6.7.0.0 + 6.8.0.0 PubNub C# .NET - Web Data Push API Pandu Masabathula PubNub @@ -23,7 +23,7 @@ http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png true https://github.com/pubnub/c-sharp/ - Added support for Users/Spaces to GrantToken. + Fixed Destroy() method when multiple Pubnub instances were in use. Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously