innovaphone.appwebsocket.Connection(url, app, password, domain)

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.

Optional parameters 'password' and 'domain' can be used to perform a password based login. This is useful when connection is established from a plain website, without myApps client (e.g. AP Manager UI uses this option for password login).

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 of the looged in user
username of the logged in user
Display name of the logged in user
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.
Boolean. If set to true, the CheckBuild mechanism will be used.
this.setKeepAlive = function (on)
Turns KeepAlive on or off. If on, a "KeepAlive" message will be sent to the server from time to time in order to detect if the connection is still up.
this.encrypt = function (seed, data)
Returns ecrypted data based on a certain seed. RC4 is used in combination with a session key which is calculated during the login handshake.
this.decrypt = function (seed, data)
Returns decrypted data based on a certain seed. RC4 is used in combination with a session key which is calculated during the login handshake.


See the protocol definition here: AppWebsocket.