cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
855
Views
0
Helpful
4
Replies

How to maintain session in Jabber Voice and Video SDK

Hi,

 

I am using Jabber voice and video SDK to create an agent desktop. I am able to make and receive calls using UCCX 12.0 sandbox.

I want to maintain the user session because every time I refresh the web page, I have to re-login.

Does the Jabber Voice and Video SDK maintain sessions anywhere?

How can I get it?

4 Replies 4

dstaudt
Cisco Employee
Cisco Employee

My understanding is that based on the way the Jabber SDK works, refreshing or otherwise navigating away from the page will invalidate/GC the JS objects instantiating the SDK functionality.  To avoid this, you can keep the SDK components in a frame, and navigate other aspects of the app in another frame, avoid/prevent navigating away from the page (e.g. via window.onbeforeunload), or implement a browser plugin/add-on that manages the SDK life-cycle independently of tabs/pages.
Note, while you can't prevent the need for the SDK to re-init and reconnect on a page refresh, by storing credentials (e.g. in browser local storage) you can avoid having to have the user manually re-login each time...

Here's how my application handles it using jQuery...

var DemoApp = null;
var JWA = {};

$(document).ready( function () {

    // save the application to survive browser refresh
    _save = function () {
        log("window", "saving begin");

        try {
            jabberwerx.util.saveGraph(DemoApp, demoConfig.appTag);
        } catch (e) {
            log("window", "saving failed: " + e.message);
        }

        DemoApp._setState(-1);
        DemoApp = null; //saved refs are no longer valid and should be invaldated
        log("window", "saving end");
    };

    // load saved application, create new one if it doesn't exist
    _load = function () {
        log("window", "loading begin");

        DemoApp = jabberwerx.util.loadGraph(demoConfig.appTag);
        if (!DemoApp) {
            log("window", "creating new application");
            DemoApp = new JWA.Application();
            DemoApp._login();
        } else {
            log("window", "application already created");
            DemoApp._login();
        }
        DemoApp._updateState();
        log("window", "loading end");
    };

    // Save app during browser refresh
    jabberwerx.$(window).bind("unload", function () {
        log("window", "onUnload begin");
        _save();
        log("DemoApp", "onUnload end");
    });

    // Here's where the application starts
    JWA.Application = jabberwerx.JWModel.extend({

        // Initialize the client and most bindings
        init: function() {
            log("DemoApp", "Application.init begin");

			this._super();
			
			var resource = demoConfig.resource + Math.floor((Math.random() * 1000000) + 1);
			log("DemoApp","Resource = " + resource)
			
            this.client = new jabberwerx.Client(resource);

.... etc ...

And at the bottom:

    }, "JWA.Application");

    jabberwerx.$.jStore.ready(function(engine) {
        engine.ready(function() {
            console.log('storage engine ready');
            openLog();
            console.log('onReady end');
            _load();
        });
    });
});

 

Noting Nick's sample is based on the Jabber XMPP SDK, I'd be curious to see how the Jabber Voice/Video SDK behaves when doing this kind of local storage 'pickling' on page navigation...

I'd do the same thing, i.e., store the app and auto login upon refresh. It could be tricky, though, since voice/video uses an add-in. I don't know how that would affect this.