|
|
@ -18,7 +18,11 @@ server.create = function create() { |
|
|
|
let server = net.createServer((socket) => { |
|
|
|
const user = new User(socket) |
|
|
|
socket.on('data', function (data) { |
|
|
|
let splitted = data.toString("ascii").split("\r\n")[0].split(" ") |
|
|
|
data.toString("ascii").split("\r\n").forEach(function (commandline) { |
|
|
|
if (commandline == "") { |
|
|
|
return |
|
|
|
} |
|
|
|
let splitted = commandline.split(" ") |
|
|
|
let tokenized = [] |
|
|
|
let lastParam = -1 |
|
|
|
for (let i = 0; i < splitted.length; i++) { |
|
|
@ -60,7 +64,7 @@ server.create = function create() { |
|
|
|
// ignoring servername and hostname, not useful these days
|
|
|
|
user.register(tokenized[1], tokenized[4]) |
|
|
|
let address = user.getAddress() |
|
|
|
socket.write(`001 ${user.nickname} :Welcome to the example IRC Project ${user.nickname}!~${user.username}@${address}`) |
|
|
|
socket.write(`:irc.example.com 001 ${user.nickname} :Welcome to the example IRC Project ${user.nickname}!~${user.username}@${address}\r\n`, "ascii") |
|
|
|
break; |
|
|
|
case "PRIVMSG": |
|
|
|
let target = userlist[tokenized[1]] |
|
|
@ -79,6 +83,7 @@ server.create = function create() { |
|
|
|
default: |
|
|
|
console.error(`Unknown command: ${command}`); |
|
|
|
} |
|
|
|
}); |
|
|
|
}).on('error', (err) => { |
|
|
|
console.error(err); |
|
|
|
}) |
|
|
|