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 targetString The service target of the new subscription.
subscriberString The user identity of the subscriber.
onSuccessEvent handler which is called when the subscription succeeds. The parameter is the target of the subscription.
onErrorEvent handler called when an error occurs during subscribe/notify. The parameter is errorCode.
onNotificationEvent handler called when a notification message is received. The parameter is a Notification object.
onEndEvent handler called when an end message is received during subscribe/notify.
extHeadersJSON 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 msgwsc.Message Message received
-
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 rehydratedDatathe 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 rehydratedSubscriptionwsc.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 ... }