appwebsocket


innovaphone.appwebsocket.Connection(url, app)

Creates an websocket connection to 'url' for an app entity named 'app'. It uses the Javascript function opener.GetLogin(app,challenge,onlogin(app, user, key)) to obtain login credentials from the web page which opened the app.

It provides a send function to send messages. The messages are provided to the send function as javascript object, which are JSON coded by the library. For receiving messages a onmessage handler is provided.

To route messages to multiple objects inside the App a mechanism is provided with the this.src constructor function. The idea is, that each object, which independtly sends and receives messages using the same websocket connection allocates an object with this constructor function. Each object is identifies itself by a name, which has to be unique within the App. Then the send and onmessage functions of this 'src' object are used to send and receive messages. This mechanism uses the 'src' member inside the JSON messages.

this.onconnected = function(domain, user, dn, appdomain) { }
To be overwritten by the app. Is called, when the connection is established.
domain
Domain of the looged in user
user
username of the logged in user
dn
Display name of the logged in user
appdomain
Domain of the App Instance to which the user is logged in
this.onmessage = function (message) { }
To be overwritten by the app. Is called when a message is received. The argument 'message' is a javascript object constructed from the received json message.
this.onerror = function (error) { }
this.onclosed = function () { }
this.src = function (src)
Constructor function to create an object, which routes received messages based on the string 'src'. This can be used, if the app contains different objects, which independently send requests and receive responses or indications. Each object may allocate a src object and set the onmessage member of this object to receive messages. If the send function of this src object is used, a member 'src' is added to each sent JSON message.
this.checkBuild
Boolean. If set to true, the CheckBuild mechanism will be used.

Messages

The following Messages are used on the websocket connection for this:

mt: "Challenge"

mt
"Challenge"
app
Name of the app entity (same as H.323 id of corresponding PBX object)

mt: "ChallengeResult"

mt
"ChallengeResult"
challenge
Challenge created by the App

mt: "Login"

mt
"Login"
app
Name of the app entity (same as H.323 id of corresponding PBX object)
user
User logged in at PBX
key
Hash calculated over <app>:<user>:<challenge>:<password>

LoginResult

mt
"LoginResult"
ok
Boolean, true if login succeeded