1
0
mirror of https://github.com/exane/not-gwent-online synced 2024-10-31 10:36:53 +00:00
not-gwent-online/server/User.js

52 lines
881 B
JavaScript
Raw Normal View History

2015-06-10 16:12:52 +00:00
var Entity = require("./Entity");
var User = (function(){
var User = function(socket){
if(!(this instanceof User)){
return (new User(socket));
}
Entity.call(this);
/**
* constructor here
*/
this.socket = socket;
this._id = socket.id;
};
User.prototype = Object.create(Entity.prototype);
var r = User.prototype;
/**
* methods && properties here
* r.property = null;
* r.getProperty = function() {...}
*/
r._id = null;
r.socket = null;
r.getID = function(){
return this._id;
}
r.joinRoom = function(room){
this.socket.join(room);
}
r.send = function(event, data, room){
room = room || null;
data = data || null;
if(!room){
this.socket.emit(event, data);
}
else {
this.socket.to(room).emit(event, data);
}
}
return User;
})();
module.exports = User;