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] tokenized[lastParam] = tokenized[lastParam] + " " + splitted[i]
} else if (splitted[i].charAt(0) == ":" && i > 0) { } else if (splitted[i].charAt(0) == ":" && i > 0) {
lastParam = i lastParam = i
tokenized[lastParam] = splitted[i]
tokenized[lastParam] = splitted[i].slice(1)
} else { } else {
tokenized[i] = splitted[i] tokenized[i] = splitted[i]
} }
@ -62,6 +62,12 @@ server.create = function create() {
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(`001 ${user.nickname} :Welcome to the example IRC Project ${user.nickname}!~${user.username}@${address}`)
break; break;
case "PRIVMSG":
let target = userlist[tokenized[1]]
let message = tokenized[2]
target.sendMsg(user, message)
break;
case "QUIT": case "QUIT":
server.closeConnection(user.nickname) server.closeConnection(user.nickname)
break; 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 module.exports = User
Loading…
Cancel
Save