--- googlecode.com/svn/trunk/public_html/meteor.js 2007/05/02 10:55:26 18 +++ googlecode.com/svn/trunk/public_html/meteor.js 2007/05/14 13:42:45 21 @@ -23,7 +23,7 @@ this.pingtimer = false; this.updatepollfreqtimer = false; this.lastrequest = 0; - this.recvtimes = new Array(); + this.recvtimes = []; this.MHostId = false; this.callback_process = function() {}; this.callback_reset = function() {}; @@ -34,9 +34,12 @@ this.frameloadtimer = false; this.debugmode = false; this.subsurl = false; + this.channels = {}; + this.channelcount = 0; + this.streamreq = false; + this.byteoffset = 0; // Documented public properties - this.channels = new Array(); this.subdomain = "data"; this.dynamicpageaddress = "push"; this.smartpoll = true; @@ -90,20 +93,24 @@ Meteor.prototype.joinChannel = function(channelname, backtrack) { if (typeof(this.channels[channelname]) != "undefined") throw "Cannot join channel "+channelname+": already subscribed"; this.channels[channelname] = {backtrack:backtrack, lastmsgreceived:0}; + if (this.debugmode) console.log("Joined channel "+channelname+", channel list follows"); + if (this.debugmode) console.log(this.channels); if (this.status != 0) this.start(); + this.channelcount++; } Meteor.prototype.leaveChannel = function(channelname) { if (typeof(this.channels[channelname]) == "undefined") throw "Cannot leave channel "+channelname+": not subscribed"; delete this.channels[channelname]; if (this.status != 0) this.start(); + this.channelcount--; } Meteor.prototype.start = function() { this.persist = (this.maxmessages)?1:0; this.smartpoll = (this.smartpoll)?1:0; this.mode = (this.mode=="stream")?"stream":"poll"; - if (!this.subdomain || this.channels.length) throw "Channel or Meteor subdomain host not specified"; + if (!this.subdomain || !this.channelcount) throw "Channel or Meteor subdomain host not specified"; this.stop(); var now = new Date(); var t = now.getTime(); @@ -112,7 +119,7 @@ if (this.maxmessages && !this.persist) surl += "&maxmessages=" + this.maxmessages; for (var c in this.channels) { surl += "&channel="+c; - if (this.channels[c].lastmsgreceived >= 0) { + 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; @@ -122,7 +129,11 @@ } this.subsurl = surl; if (this.mode=="stream") { - this.createIframe(this.subsurl); + if (document.all) { + this.createIframe(this.subsurl); + } else { + this.createIframe("http://"+this.subdomain+"."+location.hostname+"/stream.html"); + } var f = this.pollmode.bind(this); clearTimeout(this.pingtimer); this.pingtimer = setTimeout(f, this.pingtimeout); @@ -143,7 +154,6 @@ this.transferDoc.write(""); this.transferDoc.write("