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 a List of channels to all PushRecipients 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 to push(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)
    Push JSONObject message to a channel for a List of PushRecipient.
    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)
    Push a List of JSONObject messages to a list of channels for a list of PushRecipient.
  • Field Details

    • CHANNEL_CHAT

      static final java.lang.String CHANNEL_CHAT
      Chat 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_PRESENCE
      Presence 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_FRIEND
      Channel 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 PushServiceException
      Push JSONObject message to a channel for a List of PushRecipient. If push recipients is null or empty, the message will be pushed to all recipients of the channel.
      Parameters:
      channel - channel
      msg - message
      to - List of PushRecipients
      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 PushServiceException
      Push a List of JSONObject messages to a list of channels for a list of PushRecipient. If you want to send messages to push recipients and filter the recipients for each channel, use push(String, JSONObject, List) instead.
      Parameters:
      channels - List of channels
      msgs - List of messages
      to - List of PushRecipients
      Returns:
      List of message ids of all pushed messages
      Throws:
      PushServiceException
    • push

      java.util.List<java.lang.Long> push​(PushRequest pushRequest) throws PushServiceException
      Similar to push(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 PushServiceException
      Broadcast messages to a List of channels to all PushRecipients in the PushServer *except* the ones supplied in the omit list.
      Parameters:
      channels - List of channels
      msgs - List of messages
      omit - List of PushRecipients 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 PushServiceException
      Gets 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