pari: trunk r879 - in /trunk/config: cfgbasic.html home.html status.html

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Fri May 4 16:20:18 MST 2007


Author: pari
Date: Fri May  4 18:20:17 2007
New Revision: 879

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=879
Log:
** Major Change **

Until now we've been using pollEvents for keeping the http session alive.

We need an alternative because - 

*) If Esc key is pressed - all the background XHRs will be stopped including the waitevent
   effectively resulting in a session timeout
*) There is actually no need to monitor events on the server except for in status.html
*) If User takes more time for answering an alert box or a confirm dialog - 
   any new pollEvents will be called only after the user answers the dialog.
   This is often resulting in timeouts
*) This never worked in IE, Opera

The new model of making pings using setInterval should solve all these issues

For the timebeing I'm hardcoding the value 60 (60*250 milliseconds = 15 seconds) 
but this will be soon replaced by the actual httptimeout from manager.conf

-Pari


Modified:
    trunk/config/cfgbasic.html
    trunk/config/home.html
    trunk/config/status.html

Modified: trunk/config/cfgbasic.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/cfgbasic.html?view=diff&rev=879&r1=878&r2=879
==============================================================================
--- trunk/config/cfgbasic.html (original)
+++ trunk/config/cfgbasic.html Fri May  4 18:20:17 2007
@@ -45,6 +45,28 @@
 var copyright = "Copyright ©2006-2007 Digium, Inc.  All Rights Reserved.       ";
 var tooltip_default = "Move the mouse over to a field to see tooltips";
 var asterisk_guitools_inextconf = 0;
+eventeater.pingstatus = false;
+var keepPinging;
+
+function pingevery(a){
+	keepPinging = setInterval( makeping, a*250 );
+}
+
+function makeping(){
+	var tmp;
+	var opt = {
+		method: 'get',
+		parameters: "action=ping",
+		asynchronous: true,
+		onComplete: function(t){
+			//if( t.responseText.match("Authentication failed") || t.responseText =="" ){
+			//	window.clearInterval(keepPinging);
+			//}
+			// For some reason, I could not get clearInterval to work. I will fix this soon. - pari
+		}
+	};
+	tmp = new Ajax.Request( asterisk_rawmanPath, opt);
+}
 
 eventeater.eventcb = function(msgs) {
 	if (loggedon == 1){
@@ -136,7 +158,6 @@
 
 function loadscreen(srcbody) {
 	_$('mainscreen').style.display = '';
-	if (loggedon == 1){ astmanEngine.pollEvents(); }
 }
 
 function setstatus(status) {	_$('status').innerHTML = copyright + status;	}
@@ -201,7 +222,7 @@
 }
 
 astmanEngine.setURL(asterisk_rawmanPath );
-astmanEngine.setEventCallback(eventeater.eventcb);
+//astmanEngine.setEventCallback(eventeater.eventcb);
 
 function Logoff() {
 	if(!confirm("Are you sure ?")){ return true; }

Modified: trunk/config/home.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/home.html?view=diff&rev=879&r1=878&r2=879
==============================================================================
--- trunk/config/home.html (original)
+++ trunk/config/home.html Fri May  4 18:20:17 2007
@@ -53,6 +53,11 @@
 
 	if( parent.asterisk_guitools_inextconf == 0){
 		checkessentials();
+	}
+
+	if(!parent.eventeater.pingstatus){
+		parent.eventeater.pingstatus = true;
+		parent.pingevery(60);
 	}
 
 	parent.setLoggedOn(1);
@@ -94,7 +99,7 @@
 	if ( msgs[0].headers['response'] == "Success" ){
 		parent.gui_feedback("Login Successful",'blue',6000);
 		_$('statusbar').innerHTML = "<img src='images/tick.gif'><i>Connected!</i>";
-		parent.astmanEngine.pollEvents();
+		//parent.astmanEngine.pollEvents();
 		loggedOn();
 	}else if( msgs[0].headers['message'] == "Authentication failed" ){
 		parent.gui_feedback("Invalid Username/Password",'default',6000);

Modified: trunk/config/status.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/status.html?view=diff&rev=879&r1=878&r2=879
==============================================================================
--- trunk/config/status.html (original)
+++ trunk/config/status.html Fri May  4 18:20:17 2007
@@ -118,10 +118,11 @@
 	refreshChannelsList() ;
 	parent.astmanEngine.setEventCallback(parent.eventeater.eventcd );
 	parent.loadscreen(this);
+	parent.astmanEngine.pollEvents();
 }
 
 function localajaxend(){
-	parent.astmanEngine.setEventCallback(parent.eventeater.eventcb );
+	parent.astmanEngine.setEventCallback(null);
 	if( navigator.userAgent.indexOf("MSIE") != -1 ){ 
 		try{ purge( document.body ); } catch(e){ }	
 	}



More information about the asterisk-gui-commits mailing list