30 |
this.callback_eof = function() {}; |
this.callback_eof = function() {}; |
31 |
this.callback_changemode = function() {}; |
this.callback_changemode = function() {}; |
32 |
this.callback_statuschanged = function() {}; |
this.callback_statuschanged = function() {}; |
33 |
this.persist = true; |
this.persist = 1; |
34 |
this.frameloadtimer = false; |
this.frameloadtimer = false; |
35 |
this.debugmode = false; |
this.debugmode = false; |
36 |
this.subsurl = false; |
this.subsurl = false; |
42 |
// Documented public properties |
// Documented public properties |
43 |
this.subdomain = "data"; |
this.subdomain = "data"; |
44 |
this.dynamicpageaddress = "push"; |
this.dynamicpageaddress = "push"; |
45 |
this.smartpoll = true; |
this.smartpoll = 1; |
46 |
this.pollfreq = 2000; |
this.pollfreq = 2000; |
47 |
this.minpollfreq = 2000; |
this.minpollfreq = 2000; |
48 |
this.mode = "poll"; |
this.mode = "stream"; |
49 |
this.polltimeout = 30000; |
this.polltimeout = 30000; |
50 |
this.pingtimeout = 10000; |
this.pingtimeout = 10000; |
51 |
this.maxmessages = 0; |
this.maxmessages = 0; |
107 |
} |
} |
108 |
|
|
109 |
Meteor.prototype.start = function() { |
Meteor.prototype.start = function() { |
110 |
this.persist = (this.maxmessages)?1:0; |
this.persist = (this.persist)?1:0; |
111 |
this.smartpoll = (this.smartpoll)?1:0; |
this.smartpoll = (this.smartpoll)?1:0; |
112 |
this.mode = (this.mode=="stream")?"stream":"poll"; |
this.mode = (this.mode=="stream")?"stream":"poll"; |
113 |
if (!this.subdomain || !this.channelcount) throw "Channel or Meteor subdomain host not specified"; |
if (!this.subdomain || !this.channelcount) throw "Channel or Meteor subdomain host not specified"; |
127 |
this.pingtimer = setTimeout(f, this.pingtimeout); |
this.pingtimer = setTimeout(f, this.pingtimeout); |
128 |
|
|
129 |
} else { |
} else { |
130 |
this.createIframe("http://"+this.subdomain+"."+location.hostname+"/poll.html&nc="+t); |
this.createIframe("http://"+this.subdomain+"."+location.hostname+"/poll.html?nc="+t); |
131 |
this.recvtimes[0] = t; |
this.recvtimes[0] = t; |
132 |
if (this.updatepollfreqtimer) clearTimeout(this.updatepollfreqtimer); |
if (this.updatepollfreqtimer) clearTimeout(this.updatepollfreqtimer); |
133 |
this.updatepollfreqtimer = setInterval(this.updatepollfreq.bind(this), 2500); |
this.updatepollfreqtimer = setInterval(this.updatepollfreq.bind(this), 2500); |
136 |
} |
} |
137 |
|
|
138 |
Meteor.prototype.updateSubsUrl = function() { |
Meteor.prototype.updateSubsUrl = function() { |
139 |
|
|
140 |
|
// If streaming or long polling, connection should persist |
141 |
|
this.persist = (this.mode == "stream" || (this.mode=='poll' && this.maxmessages > 0)) ? 1 : 0; |
142 |
var surl = "http://" + this.subdomain + "." + location.hostname + "/" + this.dynamicpageaddress + "?id=" + this.MHostId; |
var surl = "http://" + this.subdomain + "." + location.hostname + "/" + this.dynamicpageaddress + "?id=" + this.MHostId; |
143 |
if (this.maxmessages && this.persist && this.mode != "stream") surl += "&maxmessages=" + this.maxmessages; |
if (this.persist && this.mode != "stream") surl += "&maxmessages=" + this.maxmessages; |
|
if (this.mode == "poll" && this.maxmessages == 0 && this.persist==1) this.persist=0; |
|
144 |
surl += "&persist="+this.persist; |
surl += "&persist="+this.persist; |
145 |
for (var c in this.channels) { |
for (var c in this.channels) { |
146 |
surl += "&channel="+c; |
surl += "&channel="+c; |
156 |
} |
} |
157 |
|
|
158 |
Meteor.prototype.createIframe = function(url) { |
Meteor.prototype.createIframe = function(url) { |
159 |
if (document.all) { |
delete this.transferDoc; |
160 |
|
if (document.all) try { this.transferDoc = new ActiveXObject("htmlfile") } catch(ex) { this.transferDoc = null } |
161 |
|
if (document.all && this.transferDoc) { |
162 |
this.transferDoc = new ActiveXObject("htmlfile"); |
this.transferDoc = new ActiveXObject("htmlfile"); |
163 |
this.transferDoc.open(); |
this.transferDoc.open(); |
164 |
this.transferDoc.write("<html>"); |
this.transferDoc.write("<html>"); |