Skip to content

Commit 4c10ebb

Browse files
committed
Handled HereNow call with empty channel scenario
1 parent fcd0b17 commit 4c10ebb

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

PubNubUnity/Assets/PubNub/Builders/Presence/HereNowRequestBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ protected bool CreateHereNowResult(object objChannelsDict, out Dictionary<string
201201
}
202202
} else {
203203
Dictionary<string, object>[] dictUuidsState = uuids as Dictionary<string, object>[];
204+
if (dictUuidsState != null){
204205
foreach (Dictionary<string, object> objUuidsState in dictUuidsState){
205206
PNHereNowOccupantData occupantData = new PNHereNowOccupantData();
206207

@@ -220,10 +221,9 @@ protected bool CreateHereNowResult(object objChannelsDict, out Dictionary<string
220221
occupantData.State = objUuidsState;
221222
}
222223
channelData.Occupants.Add(occupantData);
224+
}
223225
}
224226
}
225-
226-
227227
}
228228
}
229229
channelsResult.Add(channelName, channelData);

PubNubUnity/Assets/PubNub/PlayModeTests/PlayModeTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,28 @@ public IEnumerator TestTime() {
7878

7979
// pubnub.CleanUp();
8080
// }
81+
82+
[UnityTest]
83+
public IEnumerator TestHereNowEmptyChannel()
84+
{
85+
PNConfiguration pnConfiguration = PlayModeCommon.SetPNConfig(false);
86+
pnConfiguration.UUID = "UnityTestHereNowUUID";
87+
PubNub pubnub = new PubNub(pnConfiguration);
88+
string hereNowChannel = "EmptyChannel";
89+
List<string> channelList = new List<string>() { hereNowChannel };
90+
bool testReturn = false;
91+
92+
pubnub.HereNow().Channels(channelList).IncludeState(true).IncludeUUIDs(true).Async((result, status) =>
93+
{
94+
Debug.Log("status.Error:" + status.Error);
95+
Assert.True(!status.Error);
96+
bool matchResult = MatchHereNowresult(pubnub, result, channelList, pnConfiguration.UUID, true, false, false, 0, false, null);// Check occupancy-> It should be empty
97+
testReturn = !status.Error && matchResult;
98+
});
99+
yield return new WaitForSeconds(PlayModeCommon.WaitTimeBetweenCalls4);
100+
Assert.True(testReturn, "test didn't return");
101+
pubnub.CleanUp();
102+
}
81103

82104
[UnityTest]
83105
public IEnumerator TestHereNowChannels() {

0 commit comments

Comments
 (0)