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
No related branches found
No related tags found
No related merge requests found
...@@ -25,9 +25,9 @@ function JSONChat(usernum,jsonclient,host,port) { ...@@ -25,9 +25,9 @@ function JSONChat(usernum,jsonclient,host,port) {
if(usernum > 0 && system.username(usernum)) if(usernum > 0 && system.username(usernum))
usr = new User(usernum); usr = new User(usernum);
if(usr) 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) 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) if(this.nick)
this.client.subscribe("chat","channels." + this.nick.name + ".messages"); this.client.subscribe("chat","channels." + this.nick.name + ".messages");
else else
...@@ -88,11 +88,9 @@ function JSONChat(usernum,jsonclient,host,port) { ...@@ -88,11 +88,9 @@ function JSONChat(usernum,jsonclient,host,port) {
/* pass any client update packets to this function to process inbound messages/status updates */ /* pass any client update packets to this function to process inbound messages/status updates */
this.update = function(packet) { this.update = function(packet) {
var arr = packet.location.split("."); var arr = packet.location.split(".");
if(arr.shift().toUpperCase() != "CHAT")
return false;
var channel; var channel;
var usr; var usr;
var message;
while(arr.length > 0) { while(arr.length > 0) {
switch(arr.shift().toUpperCase()) { switch(arr.shift().toUpperCase()) {
...@@ -100,13 +98,28 @@ function JSONChat(usernum,jsonclient,host,port) { ...@@ -100,13 +98,28 @@ function JSONChat(usernum,jsonclient,host,port) {
channel = this.channels[arr[0].toUpperCase()]; channel = this.channels[arr[0].toUpperCase()];
break; break;
case "MESSAGES": case "MESSAGES":
channel.messages.push(packet.data); message = packet.data;
break; break;
case "USERS": case "USERS":
usr = channel.users[arr[0].toUpperCase()]; usr = channel.users[arr[0].toUpperCase()];
break; 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; return true;
} }
...@@ -152,7 +165,7 @@ function JSONChat(usernum,jsonclient,host,port) { ...@@ -152,7 +165,7 @@ function JSONChat(usernum,jsonclient,host,port) {
case "WHO": case "WHO":
var users = this.who(target); var users = this.who(target);
for(var u in users) for(var u in users)
this.channels[target.toUpperCase()].messages.push(users[u]); this.channels[target.toUpperCase()].users.push(users[u]);
break; break;
case "INVITE": case "INVITE":
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment