6 Commits

  1. 8
      src/server.js
  2. 4
      src/user.js

8
src/server.js

@ -26,7 +26,7 @@ server.create = function create() {
tokenized[lastParam] = tokenized[lastParam] + " " + splitted[i]
} else if (splitted[i].charAt(0) == ":" && i > 0) {
lastParam = i
tokenized[lastParam] = splitted[i]
tokenized[lastParam] = splitted[i].slice(1)
} else {
tokenized[i] = splitted[i]
}
@ -62,6 +62,12 @@ 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 "PRIVMSG":
let target = userlist[tokenized[1]]
let message = tokenized[2]
target.sendMsg(user, message)
break;
case "QUIT":
server.closeConnection(user.nickname)
break;

4
src/user.js

@ -34,7 +34,9 @@ function User(socket) {
}
this.sendMsg = function (from, message) {
this.connection.write(`:${from.nickname} PRIVMSG ${this.nickname} :${message}`)
}
}
module.exports = User
Loading…
Cancel
Save