-
public class PresenceEnables the presence set to be entered and subscribed to, and the historic presence set to be retrieved for a channel.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfacePresence.PresenceListenerAn interface allowing a listener to be notified of arrival of a presence message.
-
Field Summary
Fields Modifier and Type Field Description public final static StringGET_WAITFORSYNCpublic final static StringGET_CLIENTIDpublic final static StringGET_CONNECTIONIDpublic booleansyncComplete
-
Method Summary
Modifier and Type Method Description synchronized Array<PresenceMessage>get(Array<Param> params)Retrieves the current members present on the channel and the metadata for each member,such as their io.ably.lib.types.PresenceMessage.Action and ID. synchronized Array<PresenceMessage>get(boolean wait)Retrieves the current members present on the channel and the metadata for each member,such as their io.ably.lib.types.PresenceMessage.Action and ID. synchronized Array<PresenceMessage>get(String clientId, boolean wait)Retrieves the current members present on the channel and the metadata for each member,such as their io.ably.lib.types.PresenceMessage.Action and ID. voidsubscribe(Presence.PresenceListener listener, CompletionListener completionListener)Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set. voidsubscribe(Presence.PresenceListener listener)Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set. voidunsubscribe(Presence.PresenceListener listener)Deregisters a specific listener that is registered to receive PresenceMessage on the channel. voidsubscribe(PresenceMessage.Action action, Presence.PresenceListener listener, CompletionListener completionListener)Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set. voidsubscribe(PresenceMessage.Action action, Presence.PresenceListener listener)Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set. voidunsubscribe(PresenceMessage.Action action, Presence.PresenceListener listener)Deregisters a specific listener that is registered to receive PresenceMessage on the channel for a given PresenceMessage.Action. voidsubscribe(EnumSet<PresenceMessage.Action> actions, Presence.PresenceListener listener, CompletionListener completionListener)Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set. voidsubscribe(EnumSet<PresenceMessage.Action> actions, Presence.PresenceListener listener)Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set. voidunsubscribe(EnumSet<PresenceMessage.Action> actions, Presence.PresenceListener listener)Deregisters a specific listener that is registered to receive PresenceMessage on the channel for a given PresenceMessage.Action. voidunsubscribe()Deregisters all listeners currently receiving PresenceMessage for the channel. voidenter(Object data, CompletionListener listener)Enters the presence set for the channel, optionally passing a data payload.A clientId is required to be present on a channel.An optional callback may be provided to notify of the success or failure of the operation. voidupdate(Object data, CompletionListener listener)Updates the data payload for a presence member. voidleave(Object data, CompletionListener listener)Leaves the presence set for the channel.A client must have previously entered the presence set before they can leave it. voidleave(CompletionListener listener)Leaves the presence set for the channel.A client must have previously entered the presence set before they can leave it. voidenterClient(String clientId)Enters the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId. voidenterClient(String clientId, Object data)Enters the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId. voidenterClient(String clientId, Object data, CompletionListener listener)Enters the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId. voidupdateClient(String clientId)Updates the data payload for a presence member using a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.An optional callback may be provided to notify of the success or failure of the operation. voidupdateClient(String clientId, Object data)Updates the data payload for a presence member using a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.An optional callback may be provided to notify of the success or failure of the operation. voidupdateClient(String clientId, Object data, CompletionListener listener)Updates the data payload for a presence member using a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.An optional callback may be provided to notify of the success or failure of the operation. voidleaveClient(String clientId)Leaves the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId. voidleaveClient(String clientId, Object data)Leaves the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId. voidleaveClient(String clientId, Object data, CompletionListener listener)Leaves the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId. voidupdatePresence(PresenceMessage msg, CompletionListener listener)Update the presence for this channel with a given PresenceMessage update.The connection must be authenticated in a way that enables it to representthe clientId in the message. PaginatedResult<PresenceMessage>history(Array<Param> params)Retrieves a PaginatedResult object, containing an array of historical PresenceMessage objects for the channel.If the channel is configured to persist messages,then presence messages can be retrieved from history for up to 72 hours in the past.If not, presence messages can only be retrieved from history for up to two minutes in the past. voidhistoryAsync(Array<Param> params, Callback<AsyncPaginatedResult<PresenceMessage>> callback)Asynchronously retrieves a PaginatedResult object, containing an array of historical PresenceMessage objects for the channel.If the channel is configured to persist messages,then presence messages can be retrieved from history for up to 72 hours in the past.If not, presence messages can only be retrieved from history for up to two minutes in the past. -
-
Method Detail
-
get
synchronized Array<PresenceMessage> get(Array<Param> params)
Retrieves the current members present on the channel and the metadata for each member,such as their io.ably.lib.types.PresenceMessage.Action and ID.Returns an array of PresenceMessage objects.
Spec: RTP11
- Parameters:
params- the request params:waitForSync (RTP11c1) - Sets whether to wait for a full presence set synchronization between Ably and the clients onthe channel to complete before returning the results.
-
get
synchronized Array<PresenceMessage> get(boolean wait)
Retrieves the current members present on the channel and the metadata for each member,such as their io.ably.lib.types.PresenceMessage.Action and ID.Returns an array of PresenceMessage objects.
Spec: RTP11
- Parameters:
wait- (RTP11c1) - Sets whether to wait for a full presence set synchronization between Ably and the clients onthe channel to complete before returning the results.
-
get
synchronized Array<PresenceMessage> get(String clientId, boolean wait)
Retrieves the current members present on the channel and the metadata for each member,such as their io.ably.lib.types.PresenceMessage.Action and ID.Returns an array of PresenceMessage objects.
Spec: RTP11
- Parameters:
clientId- (RTP11c2) - Filters the array of returned presence members by a specific client using its ID.wait- (RTP11c1) - Sets whether to wait for a full presence set synchronization between Ably and the clients onthe channel to complete before returning the results.
-
subscribe
void subscribe(Presence.PresenceListener listener, CompletionListener completionListener)
Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set.
Spec: RTP6a
- Parameters:
listener- An event listener function.completionListener- A callback to be notified of success or failure of the channel attach operation.
-
subscribe
void subscribe(Presence.PresenceListener listener)
Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set.
Spec: RTP6a
- Parameters:
listener- An event listener function.
-
unsubscribe
void unsubscribe(Presence.PresenceListener listener)
Deregisters a specific listener that is registered to receive PresenceMessage on the channel.
Spec: RTP7a
- Parameters:
listener- An event listener function.
-
subscribe
void subscribe(PresenceMessage.Action action, Presence.PresenceListener listener, CompletionListener completionListener)
Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set.
Spec: RTP6b
- Parameters:
action- A PresenceMessage.Action to register the listener for.listener- An event listener function.completionListener- A callback to be notified of success or failure of the channel attach operation.
-
subscribe
void subscribe(PresenceMessage.Action action, Presence.PresenceListener listener)
Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set.
Spec: RTP6b
- Parameters:
action- A PresenceMessage.Action to register the listener for.listener- An event listener function.
-
unsubscribe
void unsubscribe(PresenceMessage.Action action, Presence.PresenceListener listener)
Deregisters a specific listener that is registered to receive PresenceMessage on the channel for a given PresenceMessage.Action.
Spec: RTP7b
- Parameters:
action- A specific PresenceMessage.Action to deregister the listener for.listener- An event listener function.
-
subscribe
void subscribe(EnumSet<PresenceMessage.Action> actions, Presence.PresenceListener listener, CompletionListener completionListener)
Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set.
Spec: RTP6b
- Parameters:
actions- An array of PresenceMessage.Action to register the listener for.listener- An event listener function.completionListener- A callback to be notified of success or failure of the channel attach operation.
-
subscribe
void subscribe(EnumSet<PresenceMessage.Action> actions, Presence.PresenceListener listener)
Registers a listener that is called each time a PresenceMessage matching a given PresenceMessage.Action,or an action within an array of PresenceMessage.Action, is received on the channel,such as a new member entering the presence set.
Spec: RTP6b
- Parameters:
actions- An array of PresenceMessage.Action to register the listener for.listener- An event listener function.
-
unsubscribe
void unsubscribe(EnumSet<PresenceMessage.Action> actions, Presence.PresenceListener listener)
Deregisters a specific listener that is registered to receive PresenceMessage on the channel for a given PresenceMessage.Action.
Spec: RTP7b
- Parameters:
actions- An array of specific PresenceMessage.Action to deregister the listener for.listener- An event listener function.
-
unsubscribe
void unsubscribe()
Deregisters all listeners currently receiving PresenceMessage for the channel.
Spec: RTP7a, RTE5
-
enter
void enter(Object data, CompletionListener listener)
Enters the presence set for the channel, optionally passing a data payload.A clientId is required to be present on a channel.An optional callback may be provided to notify of the success or failure of the operation.
Spec: RTP8
- Parameters:
data- The payload associated with the presence member.listener- An callback to notify of the success or failure of the operation.
-
update
void update(Object data, CompletionListener listener)
Updates the data payload for a presence member.If called before entering the presence set, this is treated as an enter event.An optional callback may be provided to notify of the success or failure of the operation.
Spec: RTP9
- Parameters:
data- The payload associated with the presence member.listener- An callback to notify of the success or failure of the operation.
-
leave
void leave(Object data, CompletionListener listener)
Leaves the presence set for the channel.A client must have previously entered the presence set before they can leave it.
Spec: RTP10
- Parameters:
data- The payload associated with the presence member.listener- a listener to notify of the success or failure of the operation.
-
leave
void leave(CompletionListener listener)
Leaves the presence set for the channel.A client must have previously entered the presence set before they can leave it.
Spec: RTP10
- Parameters:
listener- a listener to notify of the success or failure of the operation.
-
enterClient
void enterClient(String clientId)
Enters the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.
Spec: RTP4, RTP14, RTP15
- Parameters:
clientId- The ID of the client to enter into the presence set.
-
enterClient
void enterClient(String clientId, Object data)
Enters the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.
Spec: RTP4, RTP14, RTP15
- Parameters:
clientId- The ID of the client to enter into the presence set.data- The payload associated with the presence member.
-
enterClient
void enterClient(String clientId, Object data, CompletionListener listener)
Enters the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.
Spec: RTP4, RTP14, RTP15
- Parameters:
clientId- The ID of the client to enter into the presence set.data- The payload associated with the presence member.listener- An callback to notify of the success or failure of the operation.
-
updateClient
void updateClient(String clientId)
Updates the data payload for a presence member using a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.An optional callback may be provided to notify of the success or failure of the operation.
Spec: RTP15
- Parameters:
clientId- The ID of the client to update in the presence set.
-
updateClient
void updateClient(String clientId, Object data)
Updates the data payload for a presence member using a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.An optional callback may be provided to notify of the success or failure of the operation.
Spec: RTP15
- Parameters:
clientId- The ID of the client to update in the presence set.data- The payload to update for the presence member.
-
updateClient
void updateClient(String clientId, Object data, CompletionListener listener)
Updates the data payload for a presence member using a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.An optional callback may be provided to notify of the success or failure of the operation.
Spec: RTP15
- Parameters:
clientId- The ID of the client to update in the presence set.data- The payload to update for the presence member.listener- An callback to notify of the success or failure of the operation.
-
leaveClient
void leaveClient(String clientId)
Leaves the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.
Spec: RTP15
- Parameters:
clientId- The ID of the client to leave the presence set for.
-
leaveClient
void leaveClient(String clientId, Object data)
Leaves the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.
Spec: RTP15
- Parameters:
clientId- The ID of the client to leave the presence set for.data- The payload associated with the presence member.
-
leaveClient
void leaveClient(String clientId, Object data, CompletionListener listener)
Leaves the presence set of the channel for a given clientId.Enables a single client to update presence on behalf of any number of clients using a single connection.The library must have been instantiated with an API key or a token bound to a wildcard clientId.
Spec: RTP15
- Parameters:
clientId- The ID of the client to leave the presence set for.data- The payload associated with the presence member.listener- An callback to notify of the success or failure of the operation.
-
updatePresence
void updatePresence(PresenceMessage msg, CompletionListener listener)
Update the presence for this channel with a given PresenceMessage update.The connection must be authenticated in a way that enables it to representthe clientId in the message.
- Parameters:
msg- the presence messagelistener- a listener to be notified on completion of the operation.
-
history
PaginatedResult<PresenceMessage> history(Array<Param> params)
Retrieves a PaginatedResult object, containing an array of historical PresenceMessage objects for the channel.If the channel is configured to persist messages,then presence messages can be retrieved from history for up to 72 hours in the past.If not, presence messages can only be retrieved from history for up to two minutes in the past.
Spec: RTP12c
- Parameters:
params- the request params:start (RTP12a) - The time from which messages are retrieved, specified as milliseconds since the Unix epoch.
-
historyAsync
void historyAsync(Array<Param> params, Callback<AsyncPaginatedResult<PresenceMessage>> callback)
Asynchronously retrieves a PaginatedResult object, containing an array of historical PresenceMessage objects for the channel.If the channel is configured to persist messages,then presence messages can be retrieved from history for up to 72 hours in the past.If not, presence messages can only be retrieved from history for up to two minutes in the past.
Spec: RTP12c
- Parameters:
params- the request params:start (RTP12a) - The time from which messages are retrieved, specified as milliseconds since the Unix epoch.callback- A Callback returning AsyncPaginatedResult object containing an array of PresenceMessage objects.
-
-
-
-