|
|
@ -9,6 +9,7 @@ const ERR_UNKNOWNCOMMAND = '421' |
|
|
|
const ERR_ERRONEUSNICKNAME = '432' |
|
|
|
const ERR_NICKNAMEINUSE = '433' |
|
|
|
const ERR_NEEDMOREPARAMS = '461' |
|
|
|
const ERR_NONICKNAMEGIVEN = '431' |
|
|
|
|
|
|
|
let server = {} |
|
|
|
let registeredUserlist = require("../src/userlist.js") |
|
|
@ -29,17 +30,18 @@ server.create = function create() { |
|
|
|
if (tokenized[1]) { |
|
|
|
let nickname = tokenized[1] |
|
|
|
// nick collision test
|
|
|
|
console.log(Object.keys(registeredUserlist)); |
|
|
|
if (!Object.keys(registeredUserlist).includes(nickname)) { |
|
|
|
user.setNickname(nickname) |
|
|
|
registeredUserlist[nickname] = user |
|
|
|
socket.write(RPL_WELCOME, " nick " + nickname + " succesfully added.") |
|
|
|
socket.write(RPL_WELCOME, " nick " + nickname + " succesfully added.\r\n") |
|
|
|
} else { |
|
|
|
socket.write(ERR_NICKNAMEINUSE, " nickname in use") |
|
|
|
socket.write(ERR_NICKNAMEINUSE, " nickname in use\r\n") |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
socket.write("ERROR: NO NICKNAME PROVIDED") |
|
|
|
socket.write(ERR_NONICKNAMEGIVEN, " :No nickname given\r\n") |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|