|
@ -18,7 +18,11 @@ server.create = function create() { |
|
|
let server = net.createServer((socket) => { |
|
|
let server = net.createServer((socket) => { |
|
|
const user = new User(socket) |
|
|
const user = new User(socket) |
|
|
socket.on('data', function (data) { |
|
|
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 tokenized = [] |
|
|
let lastParam = -1 |
|
|
let lastParam = -1 |
|
|
for (let i = 0; i < splitted.length; i++) { |
|
|
for (let i = 0; i < splitted.length; i++) { |
|
@ -60,7 +64,7 @@ server.create = function create() { |
|
|
// ignoring servername and hostname, not useful these days
|
|
|
// ignoring servername and hostname, not useful these days
|
|
|
user.register(tokenized[1], tokenized[4]) |
|
|
user.register(tokenized[1], tokenized[4]) |
|
|
let address = user.getAddress() |
|
|
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; |
|
|
break; |
|
|
case "PRIVMSG": |
|
|
case "PRIVMSG": |
|
|
let target = userlist[tokenized[1]] |
|
|
let target = userlist[tokenized[1]] |
|
@ -79,6 +83,7 @@ server.create = function create() { |
|
|
default: |
|
|
default: |
|
|
console.error(`Unknown command: ${command}`); |
|
|
console.error(`Unknown command: ${command}`); |
|
|
} |
|
|
} |
|
|
|
|
|
}); |
|
|
}).on('error', (err) => { |
|
|
}).on('error', (err) => { |
|
|
console.error(err); |
|
|
console.error(err); |
|
|
}) |
|
|
}) |
|
|