|
@ -21,7 +21,7 @@ server.create = function create() { |
|
|
let splitted = data.toString("ascii").split("\r\n")[0].split(" ") |
|
|
let splitted = data.toString("ascii").split("\r\n")[0].split(" ") |
|
|
let tokenized = [] |
|
|
let tokenized = [] |
|
|
let lastParam = -1 |
|
|
let lastParam = -1 |
|
|
for(let i = 0; i < splitted.length; i++) { |
|
|
|
|
|
|
|
|
for (let i = 0; i < splitted.length; i++) { |
|
|
if (lastParam > 0) { |
|
|
if (lastParam > 0) { |
|
|
tokenized[lastParam] = tokenized[lastParam] + " " + splitted[i] |
|
|
tokenized[lastParam] = tokenized[lastParam] + " " + splitted[i] |
|
|
} else if (splitted[i].charAt(0) == ":" && i > 0) { |
|
|
} else if (splitted[i].charAt(0) == ":" && i > 0) { |
|
@ -68,6 +68,9 @@ server.create = function create() { |
|
|
|
|
|
|
|
|
target.sendMsg(user, message) |
|
|
target.sendMsg(user, message) |
|
|
break; |
|
|
break; |
|
|
|
|
|
case "QUIT": |
|
|
|
|
|
server.closeConnection(user.nickname) |
|
|
|
|
|
break; |
|
|
default: |
|
|
default: |
|
|
console.error(`Unknown command: ${command}`); |
|
|
console.error(`Unknown command: ${command}`); |
|
|
} |
|
|
} |
|
@ -79,10 +82,16 @@ server.create = function create() { |
|
|
throw err; |
|
|
throw err; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
server.getUserlist = function() { |
|
|
|
|
|
|
|
|
server.getUserlist = function () { |
|
|
return userlist |
|
|
return userlist |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
server.closeConnection = function (user_nickname) { |
|
|
|
|
|
let user = userlist[user_nickname] |
|
|
|
|
|
user.closeConnection() |
|
|
|
|
|
delete userlist[user_nickname]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return server |
|
|
return server |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|