public static class Topics.TopicStream.Default extends Stream.Default implements Topics.TopicStream
Topics.TopicStream
implementation.
This logs calls to onSubscription, onUnsubscription and onTopicUpdate at 'debug' level. These implementations can be useful during development but are usually overridden to provide meaningful processing.
Topics.TopicStream.Default
Constructor and Description |
---|
Topics.TopicStream.Default() |
Modifier and Type | Method and Description |
---|---|
void |
onSubscription(String topicPath,
TopicDetails details)
Subscription notification.
|
void |
onTopicUpdate(String topicPath,
Content content,
UpdateContext context)
Topic update received.
|
void |
onUnsubscription(String topicPath,
Topics.UnsubscribeReason reason)
Unsubscription notification.
|
onClose
onError
public void onSubscription(String topicPath, TopicDetails details)
Topics.TopicStream
This method is called when a session is subscribed to a topic that matches the stream registration. This method is also called when a stream is added, for all of the session's subscriptions to topics that match the stream registration.
For a given topic, onSubscription
will be the initial
notification, and the first notification following an
unsubscription
notification if the
session re-subscribes to the topic.
This method is also called for fallback streams if the session
removes
the last stream
that selected a subscribed topic. The fallback stream will now
receive updates for the topic, starting with an immediate
notification of the currently cached value (if any).
onSubscription
in interface Topics.TopicStream
topicPath
- the topic pathdetails
- the topic details. This provides only
basic
details of the topic.public void onUnsubscription(String topicPath, Topics.UnsubscribeReason reason)
Topics.TopicStream
This method is called if the session is unsubscribed from a topic that matches the stream registration. The stream will receive no more updates for the topic unless the session re-subscribes to the topic.
This method is also called for fallback streams if the session
adds
the first
stream that selects a subscribed topic. For these notifications,
reason
will be Topics.UnsubscribeReason.STREAM_CHANGE
. The
fallback stream will no longer receive updates for the topic.
onUnsubscription
in interface Topics.TopicStream
topicPath
- the topic pathreason
- the reason for unsubscriptionpublic void onTopicUpdate(String topicPath, Content content, UpdateContext context)
Topics.TopicStream
This indicates an update to the state of a topic that is subscribed to. Both value and delta updates are notified via this method and the supplied context will indicate which.
If the stream is added with a selector which matches topics to which
the session is already subscribed, and the topic type is
JSON
, BINARY
, or
SINGLE_VALUE
), this will be called
after the subscription notification to provide the current known
value. For other topic types, the current value is not retained by
the client, and the next update received could be a delta. For such
topics it is important to add streams before subscription.
onTopicUpdate
in interface Topics.TopicStream
topicPath
- the topic pathcontent
- the topic content. The context can contain more
information about the nature of the contentcontext
- the update context which can indicate whether the
content represents the total state or a change to the stateCopyright © 2016 Push Technology Ltd. All Rights Reserved.