Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ ktlint = "12.1.0"
dokka = "2.0.0"
kotlinx_datetime = "0.6.2"
kotlinx_coroutines = "1.10.2"
pubnub_js = "9.8.1"
pubnub_swift = "9.3.2"
pubnub_js = "10.1.0"
pubnub_swift = "9.3.5"

[libraries]
retrofit2 = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit2" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,79 @@
import com.pubnub.api.java.endpoints.Endpoint;
import com.pubnub.api.models.consumer.presence.PNHereNowResult;

/**
* Obtain information about the current state of channels including a list of unique user IDs
* currently subscribed and the total occupancy count.
* <p>
*
* @see com.pubnub.api.models.consumer.presence.PNHereNowResult
*/
public interface HereNow extends Endpoint<PNHereNowResult> {
/**
* Set the channels to query for presence information.
*
* @param channels List of channel names to query.
* @return {@code this} for method chaining
* @see #channelGroups(java.util.List)
*/
HereNow channels(java.util.List<String> channels);

/**
* Set the channel groups to query for presence information.
*
* @param channelGroups List of channel group names to query.
* @return {@code this} for method chaining
* @see #channels(java.util.List)
*/
HereNow channelGroups(java.util.List<String> channelGroups);

/**
* Whether the response should include presence state information, if available.
*
* @param includeState {@code true} to include state information, {@code false} to exclude. Default: {@code false}
* @return {@code this} for method chaining
* @see #includeUUIDs(boolean)
*/
HereNow includeState(boolean includeState);

/**
* Include the list of UUIDs currently present in each channel.
*
* @param includeUUIDs {@code true} to include UUID list, {@code false} for occupancy count only. Default: {@code true}
* @return {@code this} for method chaining
* @see #includeState(boolean)
* @see #limit(int)
*/
HereNow includeUUIDs(boolean includeUUIDs);

/**
* Set the maximum number of occupants to return per channel.
* <p>
* The server enforces a maximum limit of 1000. Values outside this range will be rejected by the server.
* <p>
* Special behavior:
* <ul>
* <li>Use {@code limit = 0} to retrieve only occupancy counts without individual occupant UUIDs</li>
* </ul>
*
* @param limit Maximum number of occupants to return (0-1000). Default: 1000
* @return {@code this} for method chaining
* @see #offset(Integer) for pagination support
*/
HereNow limit(int limit);

/**
* Set the zero-based starting index for pagination through occupants.
* <p>
* Server-side validation applies:
* <ul>
* <li>Must be >= 0 (negative values will be rejected)</li>
* </ul>
* <p>
*
* @param offset Zero-based starting position (must be >= 0). Default: null (no offset)
* @return {@code this} for method chaining
* @see #limit(int) for controlling result size
*/
HereNow offset(Integer offset);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.pubnub.api.PubNubException;
import com.pubnub.api.UserId;
import com.pubnub.api.enums.PNLogVerbosity;
import com.pubnub.api.java.PubNub;
import com.pubnub.api.java.v2.PNConfiguration;
import com.pubnub.api.models.consumer.presence.PNHereNowChannelData;
Expand All @@ -17,6 +18,7 @@ public static void main(String[] args) throws PubNubException {
// Configure PubNub instance
PNConfiguration.Builder configBuilder = PNConfiguration.builder(new UserId("demoUserId"), "demo");
configBuilder.publishKey("demo");
configBuilder.logVerbosity(PNLogVerbosity.BODY);
configBuilder.secure(true);

PubNub pubnub = PubNub.create(configBuilder.build());
Expand All @@ -25,6 +27,8 @@ public static void main(String[] args) throws PubNubException {
pubnub.hereNow()
.channels(Arrays.asList("coolChannel", "coolChannel2"))
.includeUUIDs(true)
.limit(100)
.offset(10)
.async(result -> {
result.onSuccess((PNHereNowResult res) -> {

Expand Down
Loading
Loading