Skip to content
Snippets Groups Projects
Commit 16b779e8 authored by mcmlxxix's avatar mcmlxxix
Browse files

use user.alias instead of user.handle to identify. display notice on room entry/exit.

parent a91682f0
Branches
Tags
No related merge requests found
......@@ -25,9 +25,9 @@ function JSONChat(usernum,jsonclient,host,port) {
if(usernum > 0 && system.username(usernum))
usr = new User(usernum);
if(usr)
this.nick = new Nick(usr.handle,system.name,usr.ip_address);
this.nick = new Nick(usr.alias,system.name,usr.ip_address);
else if(user && user.number > 0)
this.nick = new Nick(user.handle,system.name,user.ip_address);
this.nick = new Nick(user.alias,system.name,user.ip_address);
if(this.nick)
this.client.subscribe("chat","channels." + this.nick.name + ".messages");
else
......@@ -88,25 +88,38 @@ function JSONChat(usernum,jsonclient,host,port) {
/* pass any client update packets to this function to process inbound messages/status updates */
this.update = function(packet) {
var arr = packet.location.split(".");
if(arr.shift().toUpperCase() != "CHAT")
return false;
var channel;
var usr;
var message;
while(arr.length > 0) {
switch(arr.shift().toUpperCase()) {
case "CHANNELS":
channel = this.channels[arr[0].toUpperCase()];
break;
case "MESSAGES":
channel.messages.push(packet.data);
message = packet.data;
break;
case "USERS":
usr = channel.users[arr[0].toUpperCase()];
break;
}
}
switch(packet.oper.toUpperCase()) {
case "SUBSCRIBE":
channel.messages.push(new Message("",packet.data.nick + " is here.",Date.now()));
break;
case "UNSUBSCRIBE":
channel.messages.push(new Message("",packet.data.nick + " has left.",Date.now()));
break;
case "WRITE":
channel.messages.push(message);
break;
default:
log(LOG_WARNING,"Unhandled response");
break;
}
return true;
}
......@@ -152,7 +165,7 @@ function JSONChat(usernum,jsonclient,host,port) {
case "WHO":
var users = this.who(target);
for(var u in users)
this.channels[target.toUpperCase()].messages.push(users[u]);
this.channels[target.toUpperCase()].users.push(users[u]);
break;
case "INVITE":
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment