new MessageAlertPackage(session)
Parameters:
Name | Type | Description |
---|---|---|
session |
wsc.Session | Associated session |
Returns:
MessageAlertPackage
Example
subscribeHandler = new wsc.MessageAlertPackage(wscSession);
Methods
-
createNewSubscription(target, subscriber, onSuccess, onError, onNotification, onEnd, extHeaders)
-
Creates and starts a new Subscription object.
Parameters:
Name Type Description target
String The service target of the new subscription.
subscriber
String The user identity of the subscriber.
onSuccess
Event handler which is called when the subscription succeeds. The parameter is the target of the subscription.
onError
Event handler called when an error occurs during subscribe/notify. The parameter is errorCode.
onNotification
Event handler called when a notification message is received. The parameter is a Notification object.
onEnd
Event handler called when an end message is received during subscribe/notify.
extHeaders
JSON extension headers.
Returns:
a Subscription object
Example
subscription = subscribeHandler.createNewSubscription( target,subscriber,onSubscribeSuccess,onSubscribeError,onNotification,onEnd);
Events
-
onMessage
-
For extensibility - Processes a received message.
This function handles MessageAlertPackage messages, and lets you process Subscription object operations as required.
This is an SPI function, which can be overridden when the MessageAlertPackage object exposed by the WebRTC Session Controller JavaScript API is extended.Parameters:
Name Type Description msg
wsc.Message Received message
-
onRehydration
-
For extensibility - Handles the rehydration data.
This is an SPI function meant to be used when extending the objects exposed by the WebRTC Session Controller JavaScript API.
When a web page is reloaded, an application can use this method to rehydrate related session objects,
including the object created by MessageAlertPackage - Subscription.Parameters:
Name Type Description rehydratedData
the rehydrated data
-
onResurrect
-
Event handler. If an application would like to reload the session, this function is called when the page is reloaded to restore a Subscription. When the function is invoked, a wsc.Subscription object is provided as a parameter.
Parameters:
Name Type Description rehydratedSubscription
wsc.Subscription is an instance of a Subscription object that is rehydrated.
Example
subscribeHandler = new wsc.MessageAlertPackage(wscSession); if (subscribeHandler) { subscribeHandler.onResurrect = onResurrect; } function onResurrect(rehydratedSubscription) { // Reset related callback functions. subscription = rehydratedSubscription; subscription.onSuccess = onSubscribeSuccess; subscription.onError = onSubscribeError; subscription.onNotification = onNotification; subscription.onShutdown = onShutdown; // Initialize other part, such as page ... }