--- googlecode.com/svn/trunk/public_html/meteor.js 2007/05/14 15:32:03 22 +++ googlecode.com/svn/trunk/public_html/meteor.js 2007/05/20 14:03:10 23 @@ -46,7 +46,7 @@ this.pollfreq = 2000; this.minpollfreq = 2000; this.mode = "poll"; - this.polltimeout=30000; + this.polltimeout = 30000; this.pingtimeout = 10000; this.maxmessages = 0; this.status = 0; @@ -115,19 +115,7 @@ var now = new Date(); var t = now.getTime(); this.setstatus(1); - var surl = "http://" + this.subdomain + "." + location.hostname + "/" + this.dynamicpageaddress + "?id=" + this.MHostId; - if (this.maxmessages && !this.persist) surl += "&maxmessages=" + this.maxmessages; - for (var c in this.channels) { - surl += "&channel="+c; - if (this.channels[c].lastmsgreceived > 0) { - surl += "&restartfrom="+this.channels[c].lastmsgreceived; - } else if (this.channels[c].backtrack > 0) { - surl += "&backtrack="+this.channels[c].backtrack; - } else if (this.channels[c].backtrack < 0 || isNaN(this.channels[c].backtrack)) { - surl += "&restartfrom="; - } - } - this.subsurl = surl; + this.updateSubsUrl(); if (this.mode=="stream") { if (document.all) { this.createIframe(this.subsurl); @@ -139,7 +127,7 @@ this.pingtimer = setTimeout(f, this.pingtimeout); } else { - this.createIframe("http://"+this.subdomain+"."+location.hostname+"/poll.html"); + this.createIframe("http://"+this.subdomain+"."+location.hostname+"/poll.html&nc="+t); this.recvtimes[0] = t; if (this.updatepollfreqtimer) clearTimeout(this.updatepollfreqtimer); this.updatepollfreqtimer = setInterval(this.updatepollfreq.bind(this), 2500); @@ -147,6 +135,24 @@ this.lastrequest = t; } +Meteor.prototype.updateSubsUrl = function() { + var surl = "http://" + this.subdomain + "." + location.hostname + "/" + this.dynamicpageaddress + "?id=" + this.MHostId; + if (this.maxmessages && this.persist && this.mode != "stream") surl += "&maxmessages=" + this.maxmessages; + if (this.mode == "poll" && this.maxmessages == 0 && this.persist==1) this.persist=0; + surl += "&persist="+this.persist; + for (var c in this.channels) { + surl += "&channel="+c; + if (this.channels[c].lastmsgreceived > 0) { + surl += "&restartfrom="+(this.channels[c].lastmsgreceived+1); + } else if (this.channels[c].backtrack > 0) { + surl += "&backtrack="+this.channels[c].backtrack; + } else if (this.channels[c].backtrack < 0 || isNaN(this.channels[c].backtrack)) { + surl += "&restartfrom="; + } + } + this.subsurl = surl; +} + Meteor.prototype.createIframe = function(url) { if (document.all) { this.transferDoc = new ActiveXObject("htmlfile"); @@ -223,6 +229,7 @@ while (this.recvtimes.length > 5) this.recvtimes.shift(); } } + this.updateSubsUrl(); this.setstatus(5); }