|
|
@ -62,6 +62,8 @@ server.create = function create() { |
|
|
|
let address = user.getAddress() |
|
|
|
socket.write(`001 ${user.nickname} :Welcome to the example IRC Project ${user.nickname}!~${user.username}@${address}`) |
|
|
|
break; |
|
|
|
case "QUIT": |
|
|
|
server.closeConnection(user) |
|
|
|
default: |
|
|
|
console.error(`Unknown command: ${command}`); |
|
|
|
} |
|
|
@ -77,6 +79,19 @@ server.create = function create() { |
|
|
|
return userlist |
|
|
|
} |
|
|
|
|
|
|
|
server.getUserObjectFromNickName = function (nickname) { |
|
|
|
user_list = server.getUserlist() |
|
|
|
if (nickname in user_list) |
|
|
|
return user_list[nickname] |
|
|
|
} |
|
|
|
|
|
|
|
server.closeConnection = function (user_nickname) { |
|
|
|
console.log(user_nickname) |
|
|
|
userObject = server.getUserObjectFromNickName(user_nickname) |
|
|
|
userObject.closeConnection() |
|
|
|
delete server.getUserlist()[user_nickname] |
|
|
|
} |
|
|
|
|
|
|
|
return server |
|
|
|
} |
|
|
|
|
|
|
|