Skip to content

Commit ea10204

Browse files
committed
Initial changes
1 parent 28e8697 commit ea10204

File tree

15 files changed

+260
-17
lines changed

15 files changed

+260
-17
lines changed

pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/HereNow.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ public interface HereNow extends Endpoint<PNHereNowResult> {
1111
HereNow includeState(boolean includeState);
1212

1313
HereNow includeUUIDs(boolean includeUUIDs);
14+
15+
HereNow limit(int limit);
16+
17+
HereNow startFrom(Integer startFrom);
1418
}

pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/HereNowImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class HereNowImpl extends PassthroughEndpoint<PNHereNowResult> implements
2020
private List<String> channelGroups = new ArrayList<>();
2121
private boolean includeState = false;
2222
private boolean includeUUIDs = true;
23+
private int limit = 1000;
24+
private Integer startFrom = null;
2325

2426
public HereNowImpl(PubNub pubnub) {
2527
super(pubnub);
@@ -32,7 +34,9 @@ protected Endpoint<PNHereNowResult> createRemoteAction() {
3234
channels,
3335
channelGroups,
3436
includeState,
35-
includeUUIDs
37+
includeUUIDs,
38+
limit,
39+
startFrom
3640
);
3741
}
3842
}

pubnub-kotlin/pubnub-kotlin-api/src/appleMain/kotlin/com/pubnub/api/PubNubImpl.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,18 @@ class PubNubImpl(private val pubNubObjC: KMPPubNub) : PubNub {
353353
channels: List<String>,
354354
channelGroups: List<String>,
355355
includeState: Boolean,
356-
includeUUIDs: Boolean
356+
includeUUIDs: Boolean,
357+
limit: Int,
358+
startFrom: Int?
357359
): HereNow {
358360
return HereNowImpl(
359361
pubnub = pubNubObjC,
360362
channels = channels,
361363
channelGroups = channelGroups,
362364
includeState = includeState,
363-
includeUUIDs = includeUUIDs
365+
includeUUIDs = includeUUIDs,
366+
limit = limit,
367+
startFrom = startFrom
364368
)
365369
}
366370

pubnub-kotlin/pubnub-kotlin-api/src/appleMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,24 @@ class HereNowImpl(
2727
private val channels: List<String>,
2828
private val channelGroups: List<String>,
2929
private val includeState: Boolean,
30-
private val includeUUIDs: Boolean
30+
private val includeUUIDs: Boolean,
31+
private val limit: Int = 1000,
32+
private val startFrom: Int? = null,
3133
) : HereNow {
3234
override fun async(callback: Consumer<Result<PNHereNowResult>>) {
3335
pubnub.hereNowWithChannels(
3436
channels = channels,
3537
channelGroups = channelGroups,
3638
includeState = includeState,
3739
includeUUIDs = includeUUIDs,
40+
// todo pass limit and startFrom once available
41+
// limit = limit,
42+
// startFrom = startFrom,
3843
onSuccess = callback.onSuccessHandler {
3944
PNHereNowResult(
4045
totalChannels = it?.totalChannels()?.toInt() ?: 0,
4146
totalOccupancy = it?.totalOccupancy()?.toInt() ?: 0,
47+
// nextStartFrom = it?.nextStartFrom()?.toInt(), // todo uncomment once available
4248
channels = (it?.channels()?.safeCast<String, KMPHereNowChannelData>())?.mapValues { entry ->
4349
PNHereNowChannelData(
4450
channelName = entry.value.channelName(),
@@ -51,6 +57,7 @@ class HereNowImpl(
5157
}
5258
)
5359
}?.toMutableMap() ?: emptyMap<String, PNHereNowChannelData>().toMutableMap()
60+
5461
)
5562
},
5663
onFailure = callback.onFailureHandler()

pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ expect interface PubNub {
171171
channelGroups: List<String> = emptyList(),
172172
includeState: Boolean = false,
173173
includeUUIDs: Boolean = true,
174+
limit: Int = 1000,
175+
startFrom: Int? = null,
174176
): HereNow
175177

176178
fun whereNow(uuid: String = configuration.userId.value): WhereNow

pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,8 @@ actual interface PubNub : StatusEmitter, EventEmitter {
774774
channelGroups: List<String>,
775775
includeState: Boolean,
776776
includeUUIDs: Boolean,
777+
limit: Int,
778+
startFrom: Int?,
777779
): HereNow
778780

779781
/**

pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ actual interface HereNow : Endpoint<PNHereNowResult> {
1111
val channelGroups: List<String>
1212
val includeState: Boolean
1313
val includeUUIDs: Boolean
14+
val limit: Int
15+
val startFrom: Int?
1416
}

pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ actual interface PubNub {
158158
channels: List<String>,
159159
channelGroups: List<String>,
160160
includeState: Boolean,
161-
includeUUIDs: Boolean
161+
includeUUIDs: Boolean,
162+
limit: Int,
163+
startFrom: Int?
162164
): HereNow
163165

164166
actual fun whereNow(uuid: String): WhereNow

pubnub-kotlin/pubnub-kotlin-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubError.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,16 @@ enum class PubNubError(private val code: Int, val message: String) {
239239
181,
240240
"Channel and/or ChannelGroup contains empty string which is not allowed.",
241241
),
242+
243+
HERE_NOW_LIMIT_OUT_OF_RANGE(
244+
182,
245+
"HereNow limit is out of range. Valid range is 1 to 1000.",
246+
),
247+
HERE_NOW_START_FROM_OUT_OF_RANGE(
248+
183,
249+
"HereNow startFrom is out of range. Valid range is 0 to infinity.",
250+
)
251+
242252
;
243253

244254
override fun toString(): String {

pubnub-kotlin/pubnub-kotlin-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import com.pubnub.api.JsonElement
88
* @property totalChannels Total number channels matching the associated HereNow call.
99
* @property totalOccupancy Total occupancy matching the associated HereNow call.
1010
* @property channels A map with values of [PNHereNowChannelData] for each channel.
11+
* @property nextStartFrom Starting position for next page of results. Null if no more pages available.
1112
*/
1213
class PNHereNowResult(
1314
val totalChannels: Int,
1415
val totalOccupancy: Int,
1516
// TODO this should be immutable
1617
val channels: MutableMap<String, PNHereNowChannelData> = mutableMapOf(),
18+
val nextStartFrom: Int? = null,
1719
)
1820

1921
/**

0 commit comments

Comments
 (0)