35 |
this.debugmode = false; |
this.debugmode = false; |
36 |
this.subsurl = false; |
this.subsurl = false; |
37 |
this.channels = {}; |
this.channels = {}; |
38 |
|
this.channelcount = 0; |
39 |
|
this.streamreq = false; |
40 |
|
this.byteoffset = 0; |
41 |
|
|
42 |
// Documented public properties |
// Documented public properties |
43 |
this.subdomain = "data"; |
this.subdomain = "data"; |
96 |
if (this.debugmode) console.log("Joined channel "+channelname+", channel list follows"); |
if (this.debugmode) console.log("Joined channel "+channelname+", channel list follows"); |
97 |
if (this.debugmode) console.log(this.channels); |
if (this.debugmode) console.log(this.channels); |
98 |
if (this.status != 0) this.start(); |
if (this.status != 0) this.start(); |
99 |
|
this.channelcount++; |
100 |
} |
} |
101 |
|
|
102 |
Meteor.prototype.leaveChannel = function(channelname) { |
Meteor.prototype.leaveChannel = function(channelname) { |
103 |
if (typeof(this.channels[channelname]) == "undefined") throw "Cannot leave channel "+channelname+": not subscribed"; |
if (typeof(this.channels[channelname]) == "undefined") throw "Cannot leave channel "+channelname+": not subscribed"; |
104 |
delete this.channels[channelname]; |
delete this.channels[channelname]; |
105 |
if (this.status != 0) this.start(); |
if (this.status != 0) this.start(); |
106 |
|
this.channelcount--; |
107 |
} |
} |
108 |
|
|
109 |
Meteor.prototype.start = function() { |
Meteor.prototype.start = function() { |
110 |
this.persist = (this.maxmessages)?1:0; |
this.persist = (this.maxmessages)?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.channels.length) throw "Channel or Meteor subdomain host not specified"; |
if (!this.subdomain || !this.channelcount) throw "Channel or Meteor subdomain host not specified"; |
114 |
this.stop(); |
this.stop(); |
115 |
var now = new Date(); |
var now = new Date(); |
116 |
var t = now.getTime(); |
var t = now.getTime(); |
119 |
if (this.maxmessages && !this.persist) surl += "&maxmessages=" + this.maxmessages; |
if (this.maxmessages && !this.persist) surl += "&maxmessages=" + this.maxmessages; |
120 |
for (var c in this.channels) { |
for (var c in this.channels) { |
121 |
surl += "&channel="+c; |
surl += "&channel="+c; |
122 |
if (this.channels[c].lastmsgreceived >= 0) { |
if (this.channels[c].lastmsgreceived > 0) { |
123 |
surl += "&restartfrom="+this.channels[c].lastmsgreceived; |
surl += "&restartfrom="+this.channels[c].lastmsgreceived; |
124 |
} else if (this.channels[c].backtrack > 0) { |
} else if (this.channels[c].backtrack > 0) { |
125 |
surl += "&backtrack="+this.channels[c].backtrack; |
surl += "&backtrack="+this.channels[c].backtrack; |
129 |
} |
} |
130 |
this.subsurl = surl; |
this.subsurl = surl; |
131 |
if (this.mode=="stream") { |
if (this.mode=="stream") { |
132 |
this.createIframe(this.subsurl); |
if (document.all) { |
133 |
|
this.createIframe(this.subsurl); |
134 |
|
} else { |
135 |
|
this.createIframe("http://"+this.subdomain+"."+location.hostname+"/stream.html"); |
136 |
|
} |
137 |
var f = this.pollmode.bind(this); |
var f = this.pollmode.bind(this); |
138 |
clearTimeout(this.pingtimer); |
clearTimeout(this.pingtimer); |
139 |
this.pingtimer = setTimeout(f, this.pingtimeout); |
this.pingtimer = setTimeout(f, this.pingtimeout); |
170 |
ifr.style.zIndex = "-20"; |
ifr.style.zIndex = "-20"; |
171 |
ifr.setAttribute("id", "meteorframe_"+this.instID); |
ifr.setAttribute("id", "meteorframe_"+this.instID); |
172 |
ifr.Meteor = Meteor; |
ifr.Meteor = Meteor; |
173 |
var innerifr = document.createElement("IFRAME"); |
if (document.compatMode=='CSS1Compat') { |
174 |
innerifr.setAttribute("src", url); |
var innerifr = document.createElement("IFRAME"); |
175 |
innerifr.setAttribute("id", "meteorinnerframe_"+this.instID); |
innerifr.setAttribute("src", url); |
176 |
ifr.appendChild(innerifr); |
innerifr.setAttribute("id", "meteorinnerframe_"+this.instID); |
177 |
document.body.appendChild(ifr); |
ifr.appendChild(innerifr); |
178 |
|
document.body.appendChild(ifr); |
179 |
|
} else { |
180 |
|
ifr.setAttribute("src", url); |
181 |
|
document.body.appendChild(ifr); |
182 |
|
} |
183 |
} |
} |
184 |
if (this.debugmode) console.log("Loading URL '"+url+"' into frame..."); |
if (this.debugmode) console.log("Loading URL '"+url+"' into frame..."); |
185 |
var f = this.frameloadtimeout.bind(this); |
var f = this.frameloadtimeout.bind(this); |
306 |
} |
} |
307 |
} |
} |
308 |
|
|
309 |
|
|
310 |
Meteor.createCookie = function(name,value,days) { |
Meteor.createCookie = function(name,value,days) { |
311 |
if (days) { |
if (days) { |
312 |
var date = new Date(); |
var date = new Date(); |
330 |
|
|
331 |
Meteor.eraseCookie = function(name) { |
Meteor.eraseCookie = function(name) { |
332 |
createCookie(name,"",-1); |
createCookie(name,"",-1); |
|
} |
|
333 |
|
} |