Skip to content
Snippets Groups Projects
Commit 97b35e04 authored by mcmlxxix's avatar mcmlxxix
Browse files

join all existing channels on client connect (or reconnect). removed useless join() argument

parent 52ad0774
No related branches found
No related tags found
No related merge requests found
...@@ -27,12 +27,6 @@ function JSONChat(usernum,jsonclient,host,port) { ...@@ -27,12 +27,6 @@ function JSONChat(usernum,jsonclient,host,port) {
return settings; return settings;
}); });
if(!this.client) {
if(!host || isNaN(port))
throw("invalid client arguments");
this.client = new JSONClient(host,port);
}
this.connect = function() { this.connect = function() {
var usr; var usr;
if(usernum > 0 && system.username(usernum)) if(usernum > 0 && system.username(usernum))
...@@ -41,10 +35,20 @@ function JSONChat(usernum,jsonclient,host,port) { ...@@ -41,10 +35,20 @@ function JSONChat(usernum,jsonclient,host,port) {
this.nick = new Nick(usr.alias,system.name,usr.ip_address); this.nick = new Nick(usr.alias,system.name,usr.ip_address);
else if(user && user.number > 0) else if(user && user.number > 0)
this.nick = new Nick(user.alias,system.name,user.ip_address); this.nick = new Nick(user.alias,system.name,user.ip_address);
if(!this.client) {
if(!host || isNaN(port))
throw("invalid client arguments");
this.client = new JSONClient(host,port);
}
this.client.connect();
if(this.nick) if(this.nick)
this.client.subscribe("chat","channels." + this.nick.name + ".messages"); this.client.subscribe("chat","channels." + this.nick.name + ".messages");
else else
throw("invalid user number"); throw("invalid user number");
for(var c in this.channels)
this.join(c.name);
} }
this.submit = function(target,str) { this.submit = function(target,str) {
...@@ -82,7 +86,7 @@ function JSONChat(usernum,jsonclient,host,port) { ...@@ -82,7 +86,7 @@ function JSONChat(usernum,jsonclient,host,port) {
} }
} }
this.join = function(target,str) { this.join = function(target) {
this.client.subscribe("chat","channels." + target + ".messages"); this.client.subscribe("chat","channels." + target + ".messages");
this.channels[target.toUpperCase()] = new Channel(target); this.channels[target.toUpperCase()] = new Channel(target);
var index = (-1 * this.settings.MAX_HISTORY); var index = (-1 * this.settings.MAX_HISTORY);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment