diff options
-rw-r--r-- | chatserver.html | 6 | ||||
-rwxr-xr-x | chatserver.js | 3 |
2 files changed, 4 insertions, 5 deletions
diff --git a/chatserver.html b/chatserver.html index 02c0b1a..2b46d5c 100644 --- a/chatserver.html +++ b/chatserver.html @@ -108,10 +108,8 @@ ws.addEventListener("message",function(msg){ else if(cmd[0]=="#yournick")nick=cmd[1]; else if(cmd[0]=="#lobbylist")updateLobbyList(cmd.slice(1)); else if(cmd[0]=="#nicklist")updateNickList(cmd.slice(1)); - else if(cmd[0]=="#nick"){ - addMessageLine("--","<"+cmd[1]+"> is now known as <"+cmd[2]+">"); - if(cmd[1]==nick)nick=cmd[2]; - } else if(cmd[0]=="#join")addMessageLine("--","<"+cmd[1]+"> joined the lobby"); + else if(cmd[0]=="#nick")addMessageLine("--","<"+cmd[1]+"> is now known as <"+cmd[2]+">"); + else if(cmd[0]=="#join")addMessageLine("--","<"+cmd[1]+"> joined the lobby"); else if(cmd[0]=="#part")addMessageLine("--","<"+cmd[1]+"> left the lobby"); else if(cmd[0]=="#lobby")highlightLobby(cmd[1]); else if(cmd[0]=="#historystart")clearMessageHistory(); diff --git a/chatserver.js b/chatserver.js index 51ab363..ec0e839 100755 --- a/chatserver.js +++ b/chatserver.js @@ -84,9 +84,10 @@ new WebSocketServer({port:WSPORT}).on("connection",function(ws){ while(fnick(choice+i)!=-1)i++; choice+=i; } - lobbysend(lobbies[flob(uobj.lob)],"#nick "+uobj.nick+" "+choice); + lobbysend(lobbies[flob(uobj.lob)],"#nick "+uobj.nick+" "+choice,[uobj.id]); } uobj.nick=choice; + ws.send("#yournick "+uobj.nick); do_persist_lobbies(); } else if(msg.match(/^#lobbylist/)){ ws.send("#lobbylist "+lobbies.map(function(lob){return lob.id+":"+lob.name;}).join(" ")); |