Class: TopicUpdateHandler

TopicUpdateHandler

new TopicUpdateHandler()

The TopicUpdateHandler interface for exclusive updates. This interface must be implemented by the user, to be registered via Session.topics#registerUpdateSource.


A topic update handler has a lifecycle that reflects the registration state on the server. This is expressed through the callback methods. Once onClose has been called, no further interactions will occur.

When an update handler is registered it will be notified via the onRegister callback. Once registered it may be in either a

active
state, where it can provide topic updates, or a
standby
state, where it is still registered but is not allowed to perform updates. The state may be switched in any order, depending on server policy.

Methods

onActive(topicPath, updater)

State notification that this handler is now active for the specified topic path and is therefore in a valid state to send updates on topic at or below the registered topic path
Parameters:
Name Type Description
topicPath String The registration path
updater Updater An updater that can be used to update topics

onClose(topicPath, errorReason)

Called when the handler is closed. The handler will be closed if the session is closed, or if the handler is unregistered.

Once closed, no further calls will be made for the handler.

Parameters:
Name Type Description
topicPath String The registration path
errorReason diffusion.errors An optional value representing the error; this can be one of the constants defined in diffusion.errors, or a feature-specific reason. It is absent if the handler was closed because the session closed.

onRegister(topicPath, deregister)

Called when the handler has been successfully registered with the server.

A session can register a single handler for a given branch of the topic tree. If there is already a handler registered for the topic path the operation will fail and onClose will be called.

To deregister the handler, call the

deregister
function supplied.
Parameters:
Name Type Description
topicPath String The path that the handler is registered for
deregister function A function that may be called to deregister this handler

onStandBy(topicPath)

State notification that this handler is not currently allowed to provide topic updates for the specified topic path. This indicates that another TopicUpdateHandler is currently active for the given topic path.

Server policy will dictate when this handler is set as active.

If this handler was previously in a

active
state, any Updater instances for this topic path will no longer be valid for use.
Parameters:
Name Type Description
topicPath String The registration path