You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
49 lines
1.0 KiB
function User(socket) {
|
|
this.registered = false
|
|
this.nickname = ""
|
|
this.connection = socket
|
|
this.realname = ""
|
|
this.username = ""
|
|
|
|
this.setNickname = function(nickname) {
|
|
this.nickname = nickname
|
|
}
|
|
|
|
this.getNickname = function(nickname) {
|
|
return this.nickname
|
|
}
|
|
|
|
this.register = function(username, realname) {
|
|
this.username = username
|
|
this.realname = realname
|
|
this.registered = true
|
|
}
|
|
|
|
this.getAddress = function() {
|
|
return this.connection.address().address
|
|
}
|
|
this.setNickname = function (nickname) {
|
|
this.nickname = nickname
|
|
}
|
|
this.setRealName = function (realname) {
|
|
this.realname = realname
|
|
}
|
|
|
|
this.quit = function (quit_message) {
|
|
if (quit_message === undefined)
|
|
this.sendMessage("QUIT")
|
|
else this.sendMessage(("QUIT :" + quit_message))
|
|
}
|
|
|
|
this.closeConnection = function () {
|
|
socket.close()
|
|
}
|
|
|
|
this.sendMessage = function (message) {
|
|
connection.write(message)
|
|
}
|
|
|
|
|
|
}
|
|
|
|
module.exports = User
|