Class: Subscription

wsc. Subscription

Represents subscription for an event.

new Subscription()

An object of this class is created by wsc.MessageAlertPackage#createNewSubscription and returned.

See:

Methods

end(extHeaders)

Stops current subscription of message notifications.

Parameters:
Name Type Description
extHeaders JSON

extension headers.

getNotifier() → {String}

Get the notifier of this subscription. The notifier is the service identity of the subscription target.

Returns:

The name of the the notifier for this subscription.

Type
String

getSubscriber() → {String}

Get the subscriber of this subscription.

Returns:

The name of the subscriber for this subscription.

Type
String

isValid() → {boolean}

Checks whether the current subscription is active. If the current subscription is active, it returns 'true'; otherwise it returns 'false'.

Returns:
Type
boolean

Events

onEnd

Callback function to invoke when an end message for a subscription is received. The application needs to configure this callback function.
The callback function is invoked without any parameters.

Example
 function onEnd(){
 //Render the web page when the end message for current subscription is received.
   var subscribeButton = document.getElementById("subscribeButton");
   if(subscribeButton != null){
     subscribeButton.disabled = false;
   }
   removeSubscriptionInfoElem();
}

onError

Callback function to invoke when a subscription is created with an error response. The application needs to configure this callback function.
The callback function is invoked with a subscription errorCode as its parameter.

Example
 function onError(errorCode) {
   console.log("Error code: "+errorCode);
}

onNotification

Callback function to invoke when a Notify request message is received. The application needs to configure this callback function.
The callback function is invoked with a Notification wsc.Notification as a parameter.

Parameters:
Name Type Description
notification wsc.Notification

The wsc.Notification object which represents the received notification message.

Example
 function onNotification(notification) {
   console.log("The sender of the notify is: "+notification.getSender());
   console.log("The receiver of the notify is: "+notification.getReceiver());
}

onSuccess

Callback function to invoke when a subscription is created successfully. The application needs to configure this callback function.
The callback function is invoked with the target of the subscription as a parameter.

Example
 function onSubscribeSuccess(target) {
   showResults("The subscription for " + target +
    " is created successfully");
 };
Oracle® Communications WebRTC Session Controller JavaScript API Reference, E55131-03
Copyright © 2013, 2015, Oracle and/or its affiliates. All rights reserved.