23 |
this.pingtimer = false; |
this.pingtimer = false; |
24 |
this.updatepollfreqtimer = false; |
this.updatepollfreqtimer = false; |
25 |
this.lastrequest = 0; |
this.lastrequest = 0; |
26 |
this.recvtimes = new Array(); |
this.recvtimes = []; |
27 |
this.MHostId = false; |
this.MHostId = false; |
28 |
this.callback_process = function() {}; |
this.callback_process = function() {}; |
29 |
this.callback_reset = function() {}; |
this.callback_reset = function() {}; |
34 |
this.frameloadtimer = false; |
this.frameloadtimer = false; |
35 |
this.debugmode = false; |
this.debugmode = false; |
36 |
this.subsurl = false; |
this.subsurl = false; |
37 |
|
this.channels = {}; |
38 |
|
|
39 |
// Documented public properties |
// Documented public properties |
|
this.channels = new Array(); |
|
40 |
this.subdomain = "data"; |
this.subdomain = "data"; |
41 |
this.dynamicpageaddress = "push"; |
this.dynamicpageaddress = "push"; |
42 |
this.smartpoll = true; |
this.smartpoll = true; |
90 |
Meteor.prototype.joinChannel = function(channelname, backtrack) { |
Meteor.prototype.joinChannel = function(channelname, backtrack) { |
91 |
if (typeof(this.channels[channelname]) != "undefined") throw "Cannot join channel "+channelname+": already subscribed"; |
if (typeof(this.channels[channelname]) != "undefined") throw "Cannot join channel "+channelname+": already subscribed"; |
92 |
this.channels[channelname] = {backtrack:backtrack, lastmsgreceived:0}; |
this.channels[channelname] = {backtrack:backtrack, lastmsgreceived:0}; |
93 |
|
if (this.debugmode) console.log("Joined channel "+channelname+", channel list follows"); |
94 |
|
if (this.debugmode) console.log(this.channels); |
95 |
if (this.status != 0) this.start(); |
if (this.status != 0) this.start(); |
96 |
} |
} |
97 |
|
|
196 |
} |
} |
197 |
|
|
198 |
Meteor.prototype.process = function(id, channel, data) { |
Meteor.prototype.process = function(id, channel, data) { |
199 |
if (id > this.channels[channel].lastmsgreceived) { |
if (id == -1) { |
200 |
if (this.debugmode) console.log("Message "+id+" received on channel "+channel+": "+data); |
if (this.debugmode) console.log("Ping"); |
201 |
|
this.ping(); |
202 |
|
} else if (typeof(this.channels[channel]) != "undefined" && id > this.channels[channel].lastmsgreceived) { |
203 |
|
if (this.debugmode) console.log("Message "+id+" received on channel "+channel+" (last id on channel: "+this.channels[channel].lastmsgreceived+")\n"+data); |
204 |
this.callback_process(data); |
this.callback_process(data); |
205 |
this.channels[channel].lastmsgreceived = id; |
this.channels[channel].lastmsgreceived = id; |
206 |
if (this.mode=="poll") { |
if (this.mode=="poll") { |
209 |
this.recvtimes[this.recvtimes.length] = t; |
this.recvtimes[this.recvtimes.length] = t; |
210 |
while (this.recvtimes.length > 5) this.recvtimes.shift(); |
while (this.recvtimes.length > 5) this.recvtimes.shift(); |
211 |
} |
} |
|
} else if (id == -1) { |
|
|
if (this.debugmode) console.log("Ping"); |
|
|
this.ping(); |
|
212 |
} |
} |
213 |
this.setstatus(5); |
this.setstatus(5); |
214 |
} |
} |