09-06-2022 01:00 AM - edited 09-07-2022 04:05 AM
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?
09-07-2022 10:25 AM
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...
09-08-2022 08:31 AM
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();
});
});
});
09-09-2022 11:37 AM
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...
09-09-2022 11:41 AM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide