AppLinkSession

Provides properties, callbacks and functions that facilitate app-to-app communication.

AppLink is the communication channel between the Dolby Conference Phone's QML app and the Dolby Voice Hub's Web app. It is provided as part of the respective APIs of the devices: QML in the conference phone, and JavaScript in the video endpoint.

Apps establish the AppLinkSession, a communication session, to start exchanging data. See the following example. Note that this example uses a helper library named AppLinkHelper.js; refer to the Applink example document for more details.

Example:

// On the Dolby Voice Hub app, first create the dapi.appLinkSession callbacks.
// These are required before communication with the Dolby Conference Phone app
// can be established.


// Callback for when the connection protocol ends, either succeeding or failing

dapi.appLinkSession.onConnect = function(succeeded) {
   if (succeeded) {
       output("AppLinkSession connected, reachable = " + (dapi.appLinkSession.reachable ? "true" : "false"));
   } else {
       output("AppLinkSession failed to connect");
   }
}

// Callback for when the session has ended
dapi.appLinkSession.onDisconnect = function() {
   output("AppLinkSession disconnected");
}

// Callback for when a text message has been received
dapi.appLinkSession.onTextMessageReceived = function(msg) {
   output("AppLinkSession received message: '" + msg + "'");
}

// Callback for when the state of the app on the Dolby Conference Phone has changed
// (e.g. unreachable while it is reloading, etc.)
dapi.appLinkSession.onReachableChanged = function() {
   output("AppLinkSession reachable changed to " + (dapi.appLinkSession.reachable ? "true" : "false"));
}


// Once the callbacks are set up, the app can connect,
// send messages, and disconnect at will:


// Setup handlers for buttons in the app
document.getElementById("myConnectButton").onclick = function() {
// By default, it will connect to the configured Dolby Conference Phone IP address
    dapi.appLinkSession.connect("MyAppSession");
}

document.getElementById("myDisconnectButton").onclick = function() {
    dapi.appLinkSession.disconnect();
}

document.getElementById("mySendButton").onclick = function() {
    var input = document.getElementById("mySendTextField");
    var txt = input.value;
    dapi.appLinkSession.sendTextMessage(txt)
}

Member Summary

Public Members

The session name specified in the latest call to method connect.

Flag that is set to true when both sides of the session are ready for transmission.

The session address specified in the latest call to method connect.

Method Summary

Public Methods

connect(name: string, url: string)

The Dolby Voice Hub app initiates the AppLinkSession establishment process by calling the connect() API.

Terminates the session.

onConnect(callback: function(ok: boolean))

Called when a connection attempt has either succeeded or failed.

onDisconnect(callback: function(ok: boolean))

Called when the session is terminated.

Called when the value of the reachable property has changed, for example, when the app on the other side is being reloaded.

Called when a message is received.

Sends the string msg through the session.

Public Members

public name: string source

The session name specified in the latest call to method connect.

public reachable: boolean source

Flag that is set to true when both sides of the session are ready for transmission. This happens, for example, when the apps have loaded successfully.

public url: string source

The session address specified in the latest call to method connect.

Public Methods

public connect(name: string, url: string) source

The Dolby Voice Hub app initiates the AppLinkSession establishment process by calling the connect() API. The Dolby Conference Phone app receives AppLinkSession information via the newSession() signal.

Attempts to establish a session named name to the address specified by url (a WebSocket address). Note that this parameter is optional; it will normally default to an internal address with this format: ws://<Phone-IP-Address>:12346

Params:

NameTypeAttributeDescription
name string

The session name

url string
  • optional

The WebSocket address in this format: ws://<Phone-IP-Address>:12346

public disconnect() source

Terminates the session.

public onConnect(callback: function(ok: boolean)) source

Called when a connection attempt has either succeeded or failed. A flag is set to true when the connection is ready; false in case of failure.

Params:

NameTypeAttributeDescription
callback function(ok: boolean)

The callback function

public onDisconnect(callback: function(ok: boolean)) source

Called when the session is terminated.

Params:

NameTypeAttributeDescription
callback function(ok: boolean)

The callback function

public onReachableChanged(callback: function(ok: boolean)) source

Called when the value of the reachable property has changed, for example, when the app on the other side is being reloaded.

Params:

NameTypeAttributeDescription
callback function(ok: boolean)

The callback function

public onTextMessageReceived(callback: function(msg: string)) source

Called when a message is received. The message is passed in the parameter msg.

Params:

NameTypeAttributeDescription
callback function(msg: string)

The callback function

public sendTextMessage(msg: string) source

Sends the string msg through the session.

Params:

NameTypeAttributeDescription
msg string

The string msg