Interface PushService
- All Superinterfaces:
Service
public interface PushService extends Service
Convenience API for pushing notifications to the push server.
Behind the scenes, this uses a REST API to send these messages from Platform to Push Server.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CHANNEL_CHAT
Chat channel for point-to-point chat.static java.lang.String
CHANNEL_FRIEND
Channel used for sending friend request information.static java.lang.String
CHANNEL_PRESENCE
Presence channel to retrieve the online (true/false) status of friends. -
Method Summary
Modifier and Type Method Description void
broadcast(java.util.List<java.lang.String> channels, java.util.List<org.json.JSONObject> msgs, java.util.List<PushRecipient> omit)
Broadcast messages to aList
of channels to allPushRecipient
s in the PushServer *except* the ones supplied in the omit list.java.lang.String
getNotificationChannelName(java.lang.Long vcId)
Notification channel for sending notifications to the clients subscribed for it.
This channel can also be used to send system wide notification if toUser is not provided.
If vcId is null, the notification channel will be used to send notifications to subscribed clients across all instances. If vcId is NOT null, the notification channel will be used to send notifications to subscribed clients across one instance identified by the value chain id. Example: System scheduled for down time at 7pm CST, 1970 for 3 hours.java.util.Map<java.lang.String,java.lang.Boolean>
getPresenceStatus(java.util.Set<java.lang.String> userNames)
Gets user presence statuses.java.util.List<java.lang.Long>
push(PushRequest pushRequest)
Similar topush(List, List, List)
, but provides additional parameters for customizing the behavior of the push operation.java.lang.Long
push(java.lang.String channel, org.json.JSONObject msg, java.util.List<PushRecipient> to)
java.util.List<java.lang.Long>
push(java.util.List<java.lang.String> channels, java.util.List<org.json.JSONObject> msgs, java.util.List<PushRecipient> to)
-
Field Details
-
CHANNEL_CHAT
static final java.lang.String CHANNEL_CHATChat channel for point-to-point chat. The communication on this channel happens between two clients.
For example, if UserA and UserB want to chat, they MUST be subscribed to this channel.- See Also:
- Constant Field Values
-
CHANNEL_PRESENCE
static final java.lang.String CHANNEL_PRESENCEPresence channel to retrieve the online (true/false) status of friends. When the friend's online status changes, for example when friend signed in or signed out, it will be pushed to the requesting user through this channel.- See Also:
- Constant Field Values
-
CHANNEL_FRIEND
static final java.lang.String CHANNEL_FRIENDChannel used for sending friend request information. The communication on this channel happens between two clients.- See Also:
- Constant Field Values
-
-
Method Details
-
push
java.lang.Long push(java.lang.String channel, org.json.JSONObject msg, java.util.List<PushRecipient> to) throws PushServiceExceptionPushJSONObject
message to a channel for aList
ofPushRecipient
. If push recipients is null or empty, the message will be pushed to all recipients of the channel.- Parameters:
channel
- channelmsg
- messageto
-List
ofPushRecipient
s- Returns:
- message id of the pushed message
- Throws:
PushServiceException
-
push
java.util.List<java.lang.Long> push(java.util.List<java.lang.String> channels, java.util.List<org.json.JSONObject> msgs, java.util.List<PushRecipient> to) throws PushServiceExceptionPush aList
ofJSONObject
messages to a list of channels for a list ofPushRecipient
. If you want to send messages to push recipients and filter the recipients for each channel, usepush(String, JSONObject, List)
instead.- Parameters:
channels
-List
of channelsmsgs
-List
of messagesto
-List
ofPushRecipient
s- Returns:
List
of message ids of all pushed messages- Throws:
PushServiceException
-
push
Similar topush(List, List, List)
, but provides additional parameters for customizing the behavior of the push operation.- Parameters:
pushRequest
-PushRequest
- Returns:
List
of message ids of all pushed messages. If PushRequest.persist flag is set to false (it's false by default), the returned list will be empty.- Throws:
PushServiceException
-
broadcast
void broadcast(java.util.List<java.lang.String> channels, java.util.List<org.json.JSONObject> msgs, java.util.List<PushRecipient> omit) throws PushServiceExceptionBroadcast messages to aList
of channels to allPushRecipient
s in the PushServer *except* the ones supplied in the omit list.- Parameters:
channels
-List
of channelsmsgs
-List
of messagesomit
-List
ofPushRecipient
s to be omitted- Throws:
PushServiceException
-
getNotificationChannelName
java.lang.String getNotificationChannelName(java.lang.Long vcId)Notification channel for sending notifications to the clients subscribed for it.
This channel can also be used to send system wide notification if toUser is not provided.
If vcId is null, the notification channel will be used to send notifications to subscribed clients across all instances. If vcId is NOT null, the notification channel will be used to send notifications to subscribed clients across one instance identified by the value chain id. Example: System scheduled for down time at 7pm CST, 1970 for 3 hours.- Parameters:
vcId
- value chain id- Returns:
- Notification channel for the instance identified by vcId.
-
getPresenceStatus
java.util.Map<java.lang.String,java.lang.Boolean> getPresenceStatus(java.util.Set<java.lang.String> userNames) throws PushServiceExceptionGets user presence statuses.- Parameters:
userNames
- user names to fetch statuses for- Returns:
- map of user name to user status - true if user is online, false if user is offline
- Throws:
PushServiceException
-