Skip to content

Commit 90b5bb3

Browse files
committed
Fixed case for limit = 0
1 parent d986e9a commit 90b5bb3

File tree

1 file changed

+12
-4
lines changed
  • pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence

1 file changed

+12
-4
lines changed

pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowEndpoint.kt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@ class HereNowEndpoint internal constructor(
8888
override fun getEndpointGroupName(): RetryableEndpointGroup = RetryableEndpointGroup.PRESENCE
8989

9090
private fun parseSingleChannelResponse(input: Envelope<JsonElement>): PNHereNowResult {
91-
val occupants = if (includeUUIDs && input.uuids != null) {
92-
prepareOccupantData(input.uuids)
91+
val occupants = if (includeUUIDs) {
92+
when {
93+
input.uuids != null -> prepareOccupantData(input.uuids)
94+
limit == 0 -> emptyList() // Server omits uuids field when limit=0
95+
else -> prepareOccupantData(input.uuids!!) // Should be present, NPE if malformed response
96+
}
9397
} else {
9498
emptyList()
9599
}
@@ -117,8 +121,12 @@ class HereNowEndpoint internal constructor(
117121
while (channels.hasNext()) {
118122
val entry = channels.next()
119123
val uuidsField = pubnub.mapper.getField(entry.value, "uuids")
120-
val occupants = if (includeUUIDs && uuidsField != null) {
121-
prepareOccupantData(uuidsField)
124+
val occupants = if (includeUUIDs) {
125+
when {
126+
uuidsField != null -> prepareOccupantData(uuidsField)
127+
limit == 0 -> emptyList() // Server omits uuids field when limit=0
128+
else -> prepareOccupantData(uuidsField!!) // Should be present, NPE if malformed response
129+
}
122130
} else {
123131
emptyList()
124132
}

0 commit comments

Comments
 (0)