X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=js%2Fpz2.js;h=50ecd0121a35a3d2e8b2a1f82ace46c8d7b1a232;hb=c4d61f7da9aa32ec5cba3971f3826e20cb46ee29;hp=c2568004995f3c36c70602a41f262d437868d4f2;hpb=c049bb4a3ff37089474950a62efaada8eeb1c820;p=pazpar2-moved-to-github.git diff --git a/js/pz2.js b/js/pz2.js index c256800..50ecd01 100644 --- a/js/pz2.js +++ b/js/pz2.js @@ -91,6 +91,7 @@ var pz2 = function ( paramArray ) this.currRecOffset = null; //timers + this.pingTimer = null; this.statTime = paramArray.stattime || 1000; this.statTimer = null; this.termTime = paramArray.termtime || 1000; @@ -158,6 +159,7 @@ pz2.prototype = this.sessionID = null; this.initStatusOK = false; this.pingStatusOK = false; + clearTimeout(this.pingTimer); } this.searchStatusOK = false; this.stop(); @@ -196,12 +198,13 @@ pz2.prototype = context.sessionID = data.getElementsByTagName("session")[0] .childNodes[0].nodeValue; - setTimeout( - function () { - context.ping(); - }, - context.keepAlive - ); + context.pingTimer = + setTimeout( + function () { + context.ping(); + }, + context.keepAlive + ); if ( context.initCallback ) context.initCallback(); } @@ -224,6 +227,9 @@ pz2.prototype = 'Pz2.js: Ping not allowed (proxy mode) or session not initialized.' ); var context = this; + + clearTimeout(context.pingTimer); + var request = new pzHttpRequest(this.pz2String, this.errorHandler); request.safeGet( { "command": "ping", "session": this.sessionID, "windowid" : window.name }, @@ -231,12 +237,13 @@ pz2.prototype = if ( data.getElementsByTagName("status")[0] .childNodes[0].nodeValue == "OK" ) { context.pingStatusOK = true; - setTimeout( - function () { - context.ping(); - }, - context.keepAlive - ); + context.pingTimer = + setTimeout( + function () { + context.ping(); + }, + context.keepAlive + ); } else context.throwError('Ping failed. Malformed WS resonse.',