/[meteor]/googlecode.com/svn/trunk/public_html/meteor.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /googlecode.com/svn/trunk/public_html/meteor.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 8 by andrew.betts, Thu Nov 23 16:35:37 2006 UTC revision 9 by andrew.betts, Fri Dec 8 16:52:58 2006 UTC
# Line 29  function addUnLoadEvent(func) { Line 29  function addUnLoadEvent(func) {
29      }      }
30    }    }
31  }  }
32  addUnLoadEvent(meteordestroy);  //addUnLoadEvent(meteordestroy);
33  function meteordestroy() {  function meteordestroy() {
34          var x = Meteor.instances.length;          var x = Meteor.instances.length;
35          for(var i=0; i<x; i++) {          for(var i=0; i<x; i++) {
36                  if (typeof(Meteor.instances[i].transferDoc)=="object") {                  Meteor.instances[i].stop();
                         Meteor.instances[i].transferDoc.open();  
                         Meteor.instances[i].transferDoc.close();  
                         delete Meteor.instances[i].transferDoc;  
                 }  
                 if (document.getElementById("meteorframe_"+Meteor.instances[i].instID)) {  
                         document.body.removeChild(document.getElementById("meteorframe_"+Meteor.instances[i].instID));  
                 }  
37                  delete Meteor.instances[i];                  delete Meteor.instances[i];
38          }          }
39  }  }
# Line 85  function Meteor(instID) { Line 78  function Meteor(instID) {
78                                          5 = Receiving data                                          5 = Receiving data
79          */          */
80    
         // Set or retrieve host id.  Cookie takes this form:  
         // MeteorID=123:6356353/124:098320454;  
         var MeteIds = Meteor.readCookie("MeteorID");  
         var regex1 = new RegExp("^([0-9\:\/M]+\/)*"+instID+"\:([^\/]+)(\/[0-9\:\/M]+)*$");  
         var regex2 = new RegExp("^([0-9\:\/M]+\/)*M\:([^\/]+)(\/[0-9\:\/M]+)*$");  
         if (typeof(instID) == "Number" && regex1.exec(MeteIds)) {  
                 this.MHostId = ma[2];  
         } else if (typeof(instID) == "Number") {  
                 this.MHostId = Math.floor(Math.random()*1000000);  
                 var newcookie = (MeteIds)?MeteIds+"/":"";  
                 newcookie += instID+":"+this.MHostId;  
                 Meteor.createCookie("MeteorID", newcookie);  
         } else if (ma = regex2.exec(MeteIds)) {  
                 this.MHostId = ma[2];  
         } else {  
                 this.MHostId = Math.floor(Math.random()*1000000);  
                 var newcookie = (MeteIds)?MeteIds+"/":"";  
                 newcookie += "M:"+this.MHostId;  
                 Meteor.createCookie("MeteorID", newcookie);  
         }  
81          this.instID = (typeof(instID) != "undefined") ? instID : 0;          this.instID = (typeof(instID) != "undefined") ? instID : 0;
82            this.MHostId = Math.floor(Math.random()*100000000)+this.instID;
83  }  }
84    
85  Meteor.instances = new Array();  Meteor.instances = new Array();
86  Meteor.servertimeoffset = 0;  Meteor.servertimeoffset = 0;
87    
88  Meteor.create = function(instID) {  Meteor.create = function(instID) {
89          if (!instID) instID = 0;          if (!instID) instID = Meteor.instances.length;
90          Meteor.instances[instID] = new Meteor(instID);          Meteor.instances[instID] = new Meteor(instID);
91          return Meteor.instances[instID];          return Meteor.instances[instID];
92  }  }
# Line 213  Meteor.prototype.start = function() { Line 187  Meteor.prototype.start = function() {
187          this.lastrequest = t;          this.lastrequest = t;
188  }  }
189    
190    Meteor.prototype.stop = function() {
191            if (typeof(this.transferDoc)=="object") {
192                    this.transferDoc.open();
193                    this.transferDoc.close();
194                    delete this.transferDoc;
195            }
196            if (document.getElementById("meteorframe_"+this.instID)) {
197                    document.getElementById("meteorframe_"+this.instID).src="about:blank";
198                    document.body.removeChild(document.getElementById("meteorframe_"+this.instID));
199            }
200            if (!isNaN(this.pingtimer)) clearTimeout(this.pingtimer);
201            if (!isNaN(this.updatepollfreqtimer)) clearTimeout(this.updatepollfreqtimer);
202            if (!isNaN(this.frameloadtimer)) clearTimeout(this.frameloadtimer);
203            this.setstatus(0);
204    }
205    
206  Meteor.prototype.pollmode = function() {  Meteor.prototype.pollmode = function() {
207          this.mode="poll";          this.mode="poll";
208          this.start();          this.start();
# Line 220  Meteor.prototype.pollmode = function() { Line 210  Meteor.prototype.pollmode = function() {
210          this.lastpingtime = false;          this.lastpingtime = false;
211  }  }
212    
213  Meteor.prototype.process = function(id, data) {  Meteor.prototype.process = function(id, data, timestamp) {
214          if (id > this.lastmsgreceived) {          if (id > this.lastmsgreceived) {
215                  this.callback_process(data);                  this.callback_process(data);
216                  if (id != -1) this.lastmsgreceived = id;                  if (id != -1) this.lastmsgreceived = id;
# Line 234  Meteor.prototype.process = function(id, Line 224  Meteor.prototype.process = function(id,
224                  this.ping();                  this.ping();
225          }          }
226          this.setstatus(5);          this.setstatus(5);
227            if (!isNaN(timestamp)) {
228                    Meteor.setServerTime(timestamp);
229            }
230  }  }
231    
232  Meteor.prototype.ping = function() {  Meteor.prototype.ping = function() {

Legend:
Removed from v.8  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26