36 |
ifr.p = Meteor.process; |
ifr.p = Meteor.process; |
37 |
ifr.r = Meteor.reset; |
ifr.r = Meteor.reset; |
38 |
ifr.eof = Meteor.eof; |
ifr.eof = Meteor.eof; |
39 |
|
ifr.ch = Meteor.channelInfo; |
40 |
clearTimeout(Meteor.frameloadtimer); |
clearTimeout(Meteor.frameloadtimer); |
41 |
Meteor.setstatus(4); |
Meteor.setstatus(4); |
42 |
Meteor.log("Frame registered"); |
Meteor.log("Frame registered"); |
96 |
clearTimeout(Meteor.updatepollfreqtimer); |
clearTimeout(Meteor.updatepollfreqtimer); |
97 |
clearTimeout(Meteor.frameloadtimer); |
clearTimeout(Meteor.frameloadtimer); |
98 |
if (typeof CollectGarbage == 'function') CollectGarbage(); |
if (typeof CollectGarbage == 'function') CollectGarbage(); |
99 |
Meteor.setstatus(0); |
if (Meteor.status != 6) Meteor.setstatus(0); |
100 |
|
Meteor.log("Disconnected"); |
101 |
} |
} |
102 |
}, |
}, |
103 |
|
|
122 |
surl += ".h"; |
surl += ".h"; |
123 |
} |
} |
124 |
} |
} |
125 |
|
var now = new Date(); |
126 |
|
surl += "?nc="+now.getTime(); |
127 |
return surl; |
return surl; |
128 |
}, |
}, |
129 |
|
|
164 |
|
|
165 |
pollmode: function() { |
pollmode: function() { |
166 |
Meteor.log("Ping timeout"); |
Meteor.log("Ping timeout"); |
167 |
Meteor.mode="simplepoll"; |
Meteor.mode="smartpoll"; |
168 |
clearTimeout(Meteor.pingtimer); |
clearTimeout(Meteor.pingtimer); |
|
Meteor.connect(); |
|
169 |
Meteor.callbacks["changemode"]("poll"); |
Meteor.callbacks["changemode"]("poll"); |
170 |
Meteor.lastpingtime = false; |
Meteor.lastpingtime = false; |
171 |
|
Meteor.connect(); |
172 |
}, |
}, |
173 |
|
|
174 |
process: function(id, channel, data) { |
process: function(id, channel, data) { |
175 |
if (id == -1) { |
if (id == -1) { |
176 |
Meteor.log("Ping"); |
Meteor.log("Ping"); |
177 |
Meteor.ping(); |
Meteor.ping(); |
178 |
} else if (typeof(Meteor.channels[channel]) != "undefined" && id > Meteor.channels[channel].lastmsgreceived) { |
} else if (typeof(Meteor.channels[channel]) != "undefined") { |
179 |
Meteor.log("Message "+id+" received on channel "+channel+" (last id on channel: "+Meteor.channels[channel].lastmsgreceived+")\n"+data); |
Meteor.log("Message "+id+" received on channel "+channel+" (last id on channel: "+Meteor.channels[channel].lastmsgreceived+")\n"+data); |
180 |
Meteor.callbacks["process"](data); |
Meteor.callbacks["process"](data); |
181 |
Meteor.channels[channel].lastmsgreceived = id; |
Meteor.channels[channel].lastmsgreceived = id; |
199 |
}, |
}, |
200 |
|
|
201 |
reset: function() { |
reset: function() { |
202 |
Meteor.log("Stream reset"); |
if (Meteor.status != 6) { |
203 |
Meteor.ping(); |
Meteor.log("Stream reset"); |
204 |
Meteor.callbacks["reset"](); |
Meteor.ping(); |
205 |
var now = new Date(); |
Meteor.callbacks["reset"](); |
206 |
var t = now.getTime(); |
var now = new Date(); |
207 |
var x = Meteor.pollfreq - (t-Meteor.lastrequest); |
var t = now.getTime(); |
208 |
if (x < 10) x = 10; |
var x = Meteor.pollfreq - (t-Meteor.lastrequest); |
209 |
setTimeout(Meteor.connect, x); |
if (x < 10) x = 10; |
210 |
|
setTimeout(Meteor.connect, x); |
211 |
|
} |
212 |
}, |
}, |
213 |
|
|
214 |
eof: function() { |
eof: function() { |
215 |
|
Meteor.log("Received end of stream, will not reconnect"); |
216 |
Meteor.callbacks["eof"](); |
Meteor.callbacks["eof"](); |
217 |
|
Meteor.setstatus(6); |
218 |
|
Meteor.disconnect(); |
219 |
|
}, |
220 |
|
|
221 |
|
channelInfo: function(channel, id) { |
222 |
|
Meteor.channels[channel].lastmsgreceived = id; |
223 |
|
Meteor.log("Received channel info for channel "+channel+": resume from "+id); |
224 |
}, |
}, |
225 |
|
|
226 |
updatepollfreq: function() { |
updatepollfreq: function() { |
256 |
Meteor.log("Frame load timeout"); |
Meteor.log("Frame load timeout"); |
257 |
if (Meteor.frameloadtimer) clearTimeout(Meteor.frameloadtimer); |
if (Meteor.frameloadtimer) clearTimeout(Meteor.frameloadtimer); |
258 |
Meteor.setstatus(3); |
Meteor.setstatus(3); |
259 |
setTimeout(Meteor.connect, 5000); |
Meteor.pollmode(); |
260 |
}, |
}, |
261 |
|
|
262 |
extract_xss_domain: function(old_domain) { |
extract_xss_domain: function(old_domain) { |
272 |
// 3 = Controller frame timeout, retrying. |
// 3 = Controller frame timeout, retrying. |
273 |
// 4 = Controller frame loaded and ready |
// 4 = Controller frame loaded and ready |
274 |
// 5 = Receiving data |
// 5 = Receiving data |
275 |
|
// 6 = End of stream, will not reconnect |
276 |
|
|
277 |
if (Meteor.status != newstatus) { |
if (Meteor.status != newstatus) { |
278 |
Meteor.status = newstatus; |
Meteor.status = newstatus; |