2014-04-23 18:44:44 +00:00
|
|
|
var _ = require("lodash");
|
|
|
|
var Chan = require("./chan");
|
|
|
|
|
|
|
|
module.exports = Network;
|
|
|
|
|
|
|
|
function Network(attr) {
|
|
|
|
_.merge(this, _.extend({
|
|
|
|
id: global.id = ++global.id || 1,
|
|
|
|
client: null,
|
|
|
|
host: "",
|
|
|
|
nick: "",
|
|
|
|
channels: [],
|
|
|
|
}, attr));
|
|
|
|
|
|
|
|
// Add lobby
|
|
|
|
this.channels.unshift(
|
2014-04-30 15:14:22 +00:00
|
|
|
new Chan({name: "Status", type: "lobby"})
|
2014-04-23 18:44:44 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2014-04-30 15:14:22 +00:00
|
|
|
Network.prototype.toJSON = function() {
|
|
|
|
var copy = _.omit(
|
|
|
|
this,
|
|
|
|
"client"
|
|
|
|
);
|
|
|
|
var name = copy.host.split(".")[1];
|
|
|
|
if (name) {
|
|
|
|
copy.host = name;
|
2014-04-23 18:44:44 +00:00
|
|
|
}
|
2014-04-30 15:14:22 +00:00
|
|
|
return copy;
|
2014-04-23 18:44:44 +00:00
|
|
|
};
|