From b9c483ef6a41582bb5618bcfe75a74ce4afbdfd8 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 20 Nov 2024 11:01:32 +0530 Subject: [PATCH] fix(presenceEventDataParsing): fixed issue in presence event data parsing arise due to change in list of serialized object values indexing differences happened after customtype introduction --- .../DeserializeToInternalObjectUtility.cs | 4 +-- .../AcceptanceTests/Steps/EventEngineSteps.cs | 29 ++++++++----------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/Api/PubnubApi/JsonDataParse/DeserializeToInternalObjectUtility.cs b/src/Api/PubnubApi/JsonDataParse/DeserializeToInternalObjectUtility.cs index e88375ef2..65a4c166d 100644 --- a/src/Api/PubnubApi/JsonDataParse/DeserializeToInternalObjectUtility.cs +++ b/src/Api/PubnubApi/JsonDataParse/DeserializeToInternalObjectUtility.cs @@ -187,8 +187,8 @@ public static T DeserializeToInternalObject(IJsonPluggableLibrary jsonPlug, L if (listObject.Count == 6) { - ack.Subscription = listObject[4].ToString(); - ack.Subscription = ack.Subscription.Replace("-pnpres", ""); + ack.Subscription = listObject[5]?.ToString(); + ack.Subscription = ack.Subscription?.Replace("-pnpres", ""); } if (listObject[1] != null) diff --git a/src/UnitTests/AcceptanceTests/Steps/EventEngineSteps.cs b/src/UnitTests/AcceptanceTests/Steps/EventEngineSteps.cs index 62345b8c6..513ed0e97 100644 --- a/src/UnitTests/AcceptanceTests/Steps/EventEngineSteps.cs +++ b/src/UnitTests/AcceptanceTests/Steps/EventEngineSteps.cs @@ -254,7 +254,6 @@ public void GivenTheDemoKeysetWithEventEngineEnabled() statusCallback = new SubscribeCallbackExt(delegate (Pubnub pnObj, PNStatus status) { pnStatus = status; - Console.WriteLine("{0} {1} {2}", pnStatus.Operation, pnStatus.Category, pnStatus.StatusCode); if (currentContract == "subscribeHandshakeFailure" && pn.PubnubUnitTest.Attempts == 3) { statusReceivedEvent.Set(); } @@ -266,30 +265,24 @@ public void GivenTheDemoKeysetWithEventEngineEnabled() subscribeCallback = new SubscribeCallbackExt( delegate (Pubnub pnObj, PNMessageResult pubMsg) { - Console.WriteLine($"Message received in listener. {pn.JsonPluggableLibrary.SerializeToJsonString(pubMsg)}"); messageResult = pubMsg; messageReceivedEvent.Set(); }, delegate (Pubnub pnObj, PNPresenceEventResult presenceEvnt) { - Console.WriteLine(pn.JsonPluggableLibrary.SerializeToJsonString(presenceEvnt)); presenceEvent.Set(); }, delegate (Pubnub pnObj, PNSignalResult signalMsg) { - Console.WriteLine(pn.JsonPluggableLibrary.SerializeToJsonString(signalMsg)); }, delegate (Pubnub pnObj, PNObjectEventResult objectEventObj) { - Console.WriteLine(pn.JsonPluggableLibrary.SerializeToJsonString(objectEventObj)); }, delegate (Pubnub pnObj, PNMessageActionEventResult msgActionEvent) { - System.Diagnostics.Debug.WriteLine(pn.JsonPluggableLibrary.SerializeToJsonString(msgActionEvent)); }, delegate (Pubnub pnObj, PNFileEventResult fileEvent) { - System.Diagnostics.Debug.WriteLine(pn.JsonPluggableLibrary.SerializeToJsonString(fileEvent)); }); } @@ -303,12 +296,14 @@ public void GivenTheDemoKeysetWithPresenceEEenabled() unitTest.IncludePnsdk = true; unitTest.IncludeUuid = true; - config = new PNConfiguration(new UserId("pn-csharp-acceptance-test-uuid")); - config.Origin = acceptance_test_origin; - config.Secure = false; - config.PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY"); - config.SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY"); - config.SecretKey = System.Environment.GetEnvironmentVariable("PN_SEC_KEY"); + config = new PNConfiguration(new UserId("pn-csharp-acceptance-test-uuid")) + { + Origin = acceptance_test_origin, + Secure = false, + PublishKey = System.Environment.GetEnvironmentVariable("PN_PUB_KEY"), + SubscribeKey = System.Environment.GetEnvironmentVariable("PN_SUB_KEY"), + SecretKey = System.Environment.GetEnvironmentVariable("PN_SEC_KEY") + }; if (enableIntenalPubnubLogging) { config.LogVerbosity = PNLogVerbosity.BODY; @@ -336,13 +331,11 @@ public void GivenTheDemoKeysetWithPresenceEEenabled() subscribeCallback = new SubscribeCallbackExt( delegate (Pubnub pnObj, PNMessageResult pubMsg) { - Console.WriteLine($"Message received in listener. {pn.JsonPluggableLibrary.SerializeToJsonString(pubMsg)}"); messageResult = pubMsg; messageReceivedEvent.Set(); }, delegate (Pubnub pnObj, PNPresenceEventResult presenceEvnt) { - Console.WriteLine(pn.JsonPluggableLibrary.SerializeToJsonString(presenceEvnt)); presenceEvent.Set(); }); } @@ -356,8 +349,10 @@ public void GivenPresenceConfiguration(string heartbeatInterval, string timeout, [When(@"I join '(.*)', '(.*)', '(.*)' channels")] public void WhenIJoinChannels(string first, string second, string third) { - pn = new Pubnub(config); - pn.PubnubUnitTest = unitTest; + pn = new Pubnub(config) + { + PubnubUnitTest = unitTest + }; pn.PubnubUnitTest.PresenceActivityList?.Clear(); messageReceivedEvent = new ManualResetEvent(false);