Refactoring
This commit is contained in:
parent
221ed4b980
commit
b3b36282aa
@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
public: true,
|
public: true,
|
||||||
host: "0.0.0.0",
|
host: "0.0.0.0",
|
||||||
port: 9090,
|
port: 9000,
|
||||||
theme: "themes/example.css",
|
theme: "themes/example.css",
|
||||||
home: "",
|
home: "",
|
||||||
debug: false
|
debug: false
|
||||||
|
@ -54,15 +54,12 @@ function Client(sockets, config) {
|
|||||||
});
|
});
|
||||||
if (config) {
|
if (config) {
|
||||||
var client = this;
|
var client = this;
|
||||||
var wait_total = 0;
|
var delay = 0;
|
||||||
_.each(config.networks || [], function(n) {
|
(config.networks || []).forEach(function(n) {
|
||||||
if (wait_total == 0)
|
setTimeout(function() {
|
||||||
client.connect(n);
|
client.connect(n);
|
||||||
else
|
}, delay);
|
||||||
setTimeout(function() {
|
delay += 1000;
|
||||||
client.connect(n);
|
|
||||||
}, wait_total);
|
|
||||||
wait_total += 500;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,11 +93,12 @@ Client.prototype.find = function(id) {
|
|||||||
|
|
||||||
Client.prototype.connect = function(args) {
|
Client.prototype.connect = function(args) {
|
||||||
var client = this;
|
var client = this;
|
||||||
var server = _.defaults(_.pick(args, ['host', 'port', 'rejectUnauthorized', 'name']), {
|
var server = {
|
||||||
host: "irc.freenode.org",
|
host: args.host || "irc.freenode.org",
|
||||||
port: args.tls ? 6697 : 6667,
|
port: args.port || (args.tls ? 6697 : 6667),
|
||||||
|
name: args.name || "",
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
});
|
};
|
||||||
|
|
||||||
var stream = args.tls ? tls.connect(server) : net.connect(server);
|
var stream = args.tls ? tls.connect(server) : net.connect(server);
|
||||||
stream.on("error", function(e) {
|
stream.on("error", function(e) {
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
|
||||||
var Helper = module.exports = {
|
var Helper = module.exports = {
|
||||||
getConfig: function () {
|
getConfig: function () {
|
||||||
return require(path.resolve(__dirname, "..", "config"));
|
return require(path.resolve(__dirname, "..", "config"));
|
||||||
},
|
},
|
||||||
|
|
||||||
getHomeDirectory: function () {
|
getHomeDirectory: function () {
|
||||||
return (
|
return (
|
||||||
this.getConfig().home ||
|
this.getConfig().home
|
||||||
process.env.SHOUT_HOME ||
|
|| process.env.SHOUT_HOME
|
||||||
path.resolve(process.env.HOME, ".shout")
|
|| path.resolve(process.env.HOME, ".shout")
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
resolveHomePath: function () {
|
resolveHomePath: function () {
|
||||||
var fragments = [ Helper.HOME ].concat([].slice.apply(arguments));
|
var fragments = [ Helper.HOME ].concat([].slice.apply(arguments));
|
||||||
return path.resolve.apply(path, fragments);
|
return path.resolve.apply(path, fragments);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Helper.HOME = Helper.getHomeDirectory()
|
Helper.HOME = Helper.getHomeDirectory()
|
||||||
|
Loading…
Reference in New Issue
Block a user