public interface NotificationManager
Interface for the notification delivery system.
Responsible for processing received topic/notification updates, subscribing for optional topic updates and unsubscribing from them.
NotificationTopicListListener
,
NotificationListenerInfo
Modifier and Type | Method and Description |
---|---|
void |
addNotificationListener(Long topicId,
NotificationListener listener)
Add listener to receive notifications relating to the specified topic.
|
void |
addNotificationListener(NotificationListener listener)
Add listener to receive all notifications (both for mandatory and
optional topics).
|
void |
addTopicListListener(NotificationTopicListListener listener)
Add listener for notification topics' list updates.
|
List<org.kaaproject.kaa.common.endpoint.gen.Topic> |
getTopics()
Retrieve a list of available notification topics.
|
void |
removeNotificationListener(Long topicId,
NotificationListener listener)
Remove listener receiving notifications for the specified topic.
|
void |
removeNotificationListener(NotificationListener listener)
Remove listener receiving all notifications (both for mandatory and
optional topics).
|
void |
removeTopicListListener(NotificationTopicListListener listener)
Remove listener of notification topics' list updates.
|
void |
subscribeToTopic(Long topicId,
boolean forceSync)
Subscribe to notifications relating to the specified optional topic.
|
void |
subscribeToTopics(List<Long> topicIds,
boolean forceSync)
Subscribe to notifications relating to the specified list of optional
topics.
|
void |
sync()
Accept optional subscription changes.
|
void |
unsubscribeFromTopic(Long topicId,
boolean forceSync)
Unsubscribe from notifications relating to the specified optional topic.
|
void |
unsubscribeFromTopics(List<Long> topicIds,
boolean forceSync)
Unsubscribe from notifications relating to the specified list of optional
topics.
|
void addTopicListListener(NotificationTopicListListener listener)
Add listener for notification topics' list updates.
listener
- the listener to receive updates.NotificationTopicListListener
void removeTopicListListener(NotificationTopicListListener listener)
Remove listener of notification topics' list updates.
listener
- listener the listener which is no longer needs updates.NotificationTopicListListener
List<org.kaaproject.kaa.common.endpoint.gen.Topic> getTopics()
Retrieve a list of available notification topics.
void addNotificationListener(NotificationListener listener)
Add listener to receive all notifications (both for mandatory and optional topics).
listener
- Listener to receive notificationsvoid addNotificationListener(Long topicId, NotificationListener listener) throws UnavailableTopicException
Add listener to receive notifications relating to the specified topic.
Listener(s) for optional topics may be added/removed irrespective to whether subscription was already or not.
topicId
- Id of topic (both mandatory and optional).listener
- Listener to receive notifications.UnavailableTopicException
- Throw if unknown topic id is provided.void removeNotificationListener(NotificationListener listener)
Remove listener receiving all notifications (both for mandatory and optional topics).
listener
- Listener to receive notificationsvoid removeNotificationListener(Long topicId, NotificationListener listener) throws UnavailableTopicException
Remove listener receiving notifications for the specified topic.
Listener(s) for optional topics may be added/removed irrespective to whether subscription was already or not.
topicId
- Id of topic (both mandatory and optional).listener
- Listener to receive notifications.UnavailableTopicException
- Throw if unknown topic id is provided.void subscribeToTopic(Long topicId, boolean forceSync) throws UnavailableTopicException
Subscribe to notifications relating to the specified optional topic.
topicId
- Id of a optional topic.forceSync
- Define whether current subscription update should be accepted
immediately (see sync()
).UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.sync()
void subscribeToTopics(List<Long> topicIds, boolean forceSync) throws UnavailableTopicException
Subscribe to notifications relating to the specified list of optional topics.
topicIds
- List of optional topic id.forceSync
- Define whether current subscription update should be accepted
immediately (see sync()
).UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.sync()
void unsubscribeFromTopic(Long topicId, boolean forceSync) throws UnavailableTopicException
Unsubscribe from notifications relating to the specified optional topic.
All previously added listeners will be removed automatically.
topicId
- Id of a optional topic.forceSync
- Define whether current subscription update should be accepted
immediately (see sync()
).UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.sync()
void unsubscribeFromTopics(List<Long> topicIds, boolean forceSync) throws UnavailableTopicException
Unsubscribe from notifications relating to the specified list of optional topics.
All previously added listeners will be removed automatically.
topicIds
- List of optional topic id.forceSync
- Define whether current subscription update should be accepted
immediately (see sync()
).UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.sync()
void sync()
Accept optional subscription changes.
Should be used after all subscribeToTopic(Long, boolean)
,
subscribeToTopics(List, boolean)
,
unsubscribeFromTopic(Long, boolean)
,
unsubscribeFromTopics(List, boolean)
calls with parameter
forceSync
set to false
.
Use it as a convenient way to make different consequent changes in the optional subscription:
{ @code NotificationManager notificationManager = kaaClient.getNotificationManager(); // Make subscription changes notificationManager.subscribeOnTopics(Arrays.asList("optional_topic1", "optional_topic2", "optional_topic3"), false); notificationManager.unsubscribeFromTopic("optional_topic4", false); // Add listeners for optional topics here // Commit changes notificationManager.sync(); }
Copyright © 2016. All rights reserved.