Connect to XMPP over HTTP (BOSH/WebSocket) using Finesse EventTunnel

To initialize the XMPP connection, the following information must be passed to the EventTunnel before it can proceed:

  1. Agent ID

  2. XMPP Domain

  3. Agent Password

  4. XMPP PubSub Domain

  5. Agent XMPP Resource (Optional)

The postMessage payload has the following message structure:

message = type + "|" + message;

where type is a number that has the following mapping:

Message Type Value Description
EVENT 0 XMPP events received by the EventTunnel and published out to the parent frame
ID 1 Agent XMPP ID
PASSWORD 2 Agent XMPP password
RESOURCEID 3 Agent XMPP resource
STATUS 4 Status of the XMPP connection published by the EventTunnel
XMPPDOMAIN 5 Domain of the XMPP service
PUBSUBDOMAIN 6 PubSub domain of the XMPP service
SUBSCRIBE 7 Request to subscribe to an XMPP node
UNSUBSCRIBE 8 Request to unsubscribe form an XMPP node
PRESENCE 9 Request to subscribe to XMPP presence
DISCONNECT_REQ 11 Request to disconnect the XMPP connection. This request attempts to unsubscribe the application from all nodes to which it subscribed during the session and then disconnects the session.

For example, a postMessage call to send the agent ID is as follows:

Code Snippet
Copymessage = "1|1001001"                               // 1 - type: ID, 1001001 - agent ID
tunnelFrame.postMessage(message, tunnelOrigin);     // where tunnelFrame is the frame
                                                    // corresponding to the iframe hosting
                                                    // the EventTunnel and tunnelOrigin is
                                                    // the URL of the EventTunnel i.e.
                                                    // http://<host>:<port> where host is
                                                    // the host of the Cisco Finesse
                                                    // server and port is the port of
                                                    // the Cisco Finesse Notification
                                                    // Service, either 7071 for http or 
                                                    // 7443 for https

Be sure to also wire up a callback to receive messages using postMessage from the EventTunnel frame, for example:

Code Snippet
Copyif (window.addEventListener) { //Firefox, Opera, Chrome, Safari
    window.addEventListener("message", cb, false);
} else { //Internet Explorer
    window.attachEvent("onmessage", cb);
}

where cb is the callback that handles any messages received using postMessage and that can parse the messages sent by the EventTunnel.