thelounge/lib/models/client.js

23 lines
396 B
JavaScript
Raw Normal View History

2014-06-29 01:07:38 +00:00
var _ = require("lodash");
2014-06-29 19:41:02 +00:00
var Network = require("./network");
2014-06-29 01:07:38 +00:00
2014-06-26 23:05:47 +00:00
module.exports = Client;
2014-06-29 01:07:38 +00:00
var id = 0;
2014-06-26 23:05:47 +00:00
function Client(attr) {
_.merge(this, _.extend({
2014-06-29 01:07:38 +00:00
id: id++,
networks: [],
2014-06-29 19:41:02 +00:00
nick: "",
keepAlive: false,
2014-06-29 01:07:38 +00:00
sockets: null
2014-06-26 23:05:47 +00:00
}, attr));
}
2014-06-29 01:07:38 +00:00
Client.prototype.emit = function(event, data) {
2014-06-29 19:41:02 +00:00
if (this.sockets !== null) {
2014-06-29 01:07:38 +00:00
this.sockets.in(this.id).emit(event, data);
}
2014-06-29 19:41:02 +00:00
};