44 |
|
|
45 |
joinChannel: function(channelname, backtrack) { |
joinChannel: function(channelname, backtrack) { |
46 |
if (typeof(Meteor.channels[channelname]) != "undefined") throw "Cannot join channel "+channelname+": already subscribed"; |
if (typeof(Meteor.channels[channelname]) != "undefined") throw "Cannot join channel "+channelname+": already subscribed"; |
47 |
Meteor.channels[channelname] = {backtrack:backtrack, lastmsgreceived:0}; |
Meteor.channels[channelname] = {backtrack:backtrack}; |
48 |
Meteor.log("Joined channel "+channelname); |
Meteor.log("Joined channel "+channelname); |
49 |
Meteor.channelcount++; |
Meteor.channelcount++; |
50 |
if (Meteor.status != 0) Meteor.connect(); |
if (Meteor.status != 0) Meteor.connect(); |
54 |
if (typeof(Meteor.channels[channelname]) == "undefined") throw "Cannot leave channel "+channelname+": not subscribed"; |
if (typeof(Meteor.channels[channelname]) == "undefined") throw "Cannot leave channel "+channelname+": not subscribed"; |
55 |
delete Meteor.channels[channelname]; |
delete Meteor.channels[channelname]; |
56 |
Meteor.log("Left channel "+channelname); |
Meteor.log("Left channel "+channelname); |
|
if (Meteor.status != 0) Meteor.connect(); |
|
57 |
Meteor.channelcount--; |
Meteor.channelcount--; |
58 |
|
if (Meteor.channelcount && Meteor.status != 0) Meteor.connect(); |
59 |
|
else Meteor.disconnect(); |
60 |
}, |
}, |
61 |
|
|
62 |
connect: function() { |
connect: function() { |
98 |
clearTimeout(Meteor.frameloadtimer); |
clearTimeout(Meteor.frameloadtimer); |
99 |
if (typeof CollectGarbage == 'function') CollectGarbage(); |
if (typeof CollectGarbage == 'function') CollectGarbage(); |
100 |
if (Meteor.status != 6) Meteor.setstatus(0); |
if (Meteor.status != 6) Meteor.setstatus(0); |
101 |
|
try { |
102 |
|
Meteor.frameref.open(); |
103 |
|
Meteor.frameref.close(); |
104 |
|
} catch (e) { |
105 |
|
Meteor.frameref.parentNode.removeChild(Meteor.frameref); |
106 |
|
} |
107 |
|
delete Meteor.frameref; |
108 |
Meteor.log("Disconnected"); |
Meteor.log("Disconnected"); |
109 |
} |
} |
110 |
}, |
}, |
122 |
var surl = "http://" + Meteor.host + ((Meteor.port==80)?"":":"+Meteor.port) + "/push/" + Meteor.hostid + "/" + Meteor.mode; |
var surl = "http://" + Meteor.host + ((Meteor.port==80)?"":":"+Meteor.port) + "/push/" + Meteor.hostid + "/" + Meteor.mode; |
123 |
for (var c in Meteor.channels) { |
for (var c in Meteor.channels) { |
124 |
surl += "/"+c; |
surl += "/"+c; |
125 |
if (Meteor.channels[c].lastmsgreceived > 0) { |
if (typeof Meteor.channels[c].lastmsgreceived != 'undefined' && Meteor.channels[c].lastmsgreceived >= 0) { |
126 |
surl += ".r"+(Meteor.channels[c].lastmsgreceived+1); |
surl += ".r"+(Meteor.channels[c].lastmsgreceived+1); |
127 |
} else if (Meteor.channels[c].backtrack > 0) { |
} else if (Meteor.channels[c].backtrack > 0) { |
128 |
surl += ".b"+Meteor.channels[c].backtrack; |
surl += ".b"+Meteor.channels[c].backtrack; |
129 |
} else if (Meteor.channels[c].backtrack < 0 || isNaN(Meteor.channels[c].backtrack)) { |
} else if (Meteor.channels[c].backtrack != undefined) { |
130 |
surl += ".h"; |
surl += ".h"; |
131 |
} |
} |
132 |
} |
} |