30 |
this.callback_reset = function() {}; |
this.callback_reset = function() {}; |
31 |
this.callback_eof = function() {}; |
this.callback_eof = function() {}; |
32 |
this.callback_changemode = function() {}; |
this.callback_changemode = function() {}; |
33 |
|
this.callback_statuschanged = function() {}; |
34 |
this.persist = true; |
this.persist = true; |
35 |
|
this.frameloadtimer = false; |
36 |
|
this.frameurl = false; |
37 |
|
|
38 |
// Documented public properties |
// Documented public properties |
39 |
this.channel = false; |
this.channel = false; |
47 |
this.polltimeout=30000; |
this.polltimeout=30000; |
48 |
this.maxmessages=0; |
this.maxmessages=0; |
49 |
this.pingtimeout = 10000; |
this.pingtimeout = 10000; |
50 |
|
this.status = 0; |
51 |
|
|
52 |
|
/* Statuses: 0 = Uninitialised, |
53 |
|
1 = Loading stream, |
54 |
|
2 = Loading controller frame, |
55 |
|
3 = Controller frame timeout, retrying every 5 seconds |
56 |
|
4 = Controller frame loaded and ready |
57 |
|
5 = Receiving data |
58 |
|
*/ |
59 |
|
|
60 |
// Set or retrieve host id. Cookie takes this form: |
// Set or retrieve host id. Cookie takes this form: |
61 |
// MeteorID=123:6356353/124:098320454; |
// MeteorID=123:6356353/124:098320454; |
97 |
ifr.eof = this.instances[instid].eof.bind(this.instances[instid]); |
ifr.eof = this.instances[instid].eof.bind(this.instances[instid]); |
98 |
ifr.get = this.instances[instid].get.bind(this.instances[instid]); |
ifr.get = this.instances[instid].get.bind(this.instances[instid]); |
99 |
ifr.increasepolldelay = this.instances[instid].increasepolldelay.bind(this.instances[instid]); |
ifr.increasepolldelay = this.instances[instid].increasepolldelay.bind(this.instances[instid]); |
100 |
|
clearTimeout(this.instances[instid].frameloadtimer); |
101 |
|
this.instances[instid].setstatus(4); |
102 |
} |
} |
103 |
|
|
104 |
Meteor.setServerTime = function(timestamp) { |
Meteor.setServerTime = function(timestamp) { |
124 |
} |
} |
125 |
if (this.mode=="stream") { |
if (this.mode=="stream") { |
126 |
if (document.all) { |
if (document.all) { |
127 |
|
this.setstatus(1); |
128 |
this.transferDoc = new ActiveXObject("htmlfile"); |
this.transferDoc = new ActiveXObject("htmlfile"); |
129 |
this.transferDoc.open(); |
this.transferDoc.open(); |
130 |
this.transferDoc.write("<html>"); |
this.transferDoc.write("<html>"); |
155 |
ifr.style.zIndex = "-20"; |
ifr.style.zIndex = "-20"; |
156 |
ifr.id = "meteorframe_"+this.instID; |
ifr.id = "meteorframe_"+this.instID; |
157 |
document.body.appendChild(ifr); |
document.body.appendChild(ifr); |
158 |
ifr.src = "http://"+this.subdomain+"."+location.hostname+"/stream.html?nocache="+t; |
this.frameurl = "http://"+this.subdomain+"."+location.hostname+"/stream.html"; |
159 |
|
this.frameload(); |
160 |
} |
} |
161 |
var f = this.pollmode.bind(this); |
var f = this.pollmode.bind(this); |
162 |
clearTimeout(this.pingtimer); |
clearTimeout(this.pingtimer); |
176 |
} |
} |
177 |
ifr.id = "meteorframe_"+this.instID; |
ifr.id = "meteorframe_"+this.instID; |
178 |
document.body.appendChild(ifr); |
document.body.appendChild(ifr); |
179 |
ifr.src = "http://"+this.subdomain+"."+location.hostname+"/poll.html?nocache="+t; |
this.frameurl = "http://"+this.subdomain+"."+location.hostname+"/poll.html"; |
180 |
|
this.frameload(); |
181 |
this.recvtimes[0] = t; |
this.recvtimes[0] = t; |
182 |
if (this.updatepollfreqtimer) clearTimeout(this.updatepollfreqtimer); |
if (this.updatepollfreqtimer) clearTimeout(this.updatepollfreqtimer); |
183 |
this.updatepollfreqtimer = setInterval(this.updatepollfreq.bind(this), 2500); |
this.updatepollfreqtimer = setInterval(this.updatepollfreq.bind(this), 2500); |
189 |
this.mode="poll"; |
this.mode="poll"; |
190 |
this.start(); |
this.start(); |
191 |
this.callback_changemode("poll"); |
this.callback_changemode("poll"); |
192 |
|
this.lastpingtime = false; |
193 |
} |
} |
194 |
|
|
195 |
Meteor.prototype.process = function(id, data) { |
Meteor.prototype.process = function(id, data) { |
205 |
} else if (id == -1) { |
} else if (id == -1) { |
206 |
this.ping(); |
this.ping(); |
207 |
} |
} |
208 |
|
this.setstatus(5); |
209 |
} |
} |
210 |
|
|
211 |
Meteor.prototype.ping = function() { |
Meteor.prototype.ping = function() { |
216 |
var now = new Date(); |
var now = new Date(); |
217 |
this.lastpingtime = now.getTime(); |
this.lastpingtime = now.getTime(); |
218 |
} |
} |
219 |
|
this.setstatus(5); |
220 |
} |
} |
221 |
|
|
222 |
Meteor.prototype.reset = function() { |
Meteor.prototype.reset = function() { |
269 |
this.callback_eof = (this.callback_eof).andThen(funcRef); |
this.callback_eof = (this.callback_eof).andThen(funcRef); |
270 |
} else if (evt=="changemode") { |
} else if (evt=="changemode") { |
271 |
this.callback_changemode = (this.callback_changemode).andThen(funcRef); |
this.callback_changemode = (this.callback_changemode).andThen(funcRef); |
272 |
|
} else if (evt=="changestatus") { |
273 |
|
this.callback_statuschanged = (this.callback_statuschanged).andThen(funcRef); |
274 |
} |
} |
275 |
} |
} |
276 |
|
|
277 |
|
Meteor.prototype.frameload = function() { |
278 |
|
this.setstatus(2); |
279 |
|
if (document.getElementById("meteorframe_"+this.instID)) { |
280 |
|
var f = this.frameloadtimeout.bind(this); |
281 |
|
this.frameloadtimer = setTimeout(f, 5000); |
282 |
|
document.getElementById("meteorframe_"+this.instID).src = "about:blank"; |
283 |
|
setTimeout(this.doloadurl.bind(this), 100); |
284 |
|
} |
285 |
|
} |
286 |
|
Meteor.prototype.doloadurl = function() { |
287 |
|
var now = new Date(); |
288 |
|
var t = now.getTime(); |
289 |
|
document.getElementById("meteorframe_"+this.instID).src = this.frameurl+"?nocache="+t; |
290 |
|
} |
291 |
|
Meteor.prototype.frameloadtimeout = function() { |
292 |
|
if (this.frameloadtimer) clearTimeout(this.frameloadtimer); |
293 |
|
this.setstatus(3); |
294 |
|
this.frameload(); |
295 |
|
} |
296 |
|
Meteor.prototype.setstatus = function(newstatus) { |
297 |
|
if (this.status != newstatus) { |
298 |
|
this.status = newstatus; |
299 |
|
this.callback_statuschanged(newstatus); |
300 |
|
} |
301 |
|
} |
302 |
|
|
303 |
Meteor.createCookie = function(name,value,days) { |
Meteor.createCookie = function(name,value,days) { |
304 |
if (days) { |
if (days) { |