global.config.restrict_server_ssl,
command.nick,
{hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address},
- global.config.restrict_server_password);
+ global.config.restrict_server_password,
+ callback);
} else {
this.state.connect(
command.ssl,
command.nick,
{hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address},
- command.password);
+ command.password,
+ callback);
}
} else {
return callback('Hostname, port and nickname must be specified');
hostname: command.hostname,
channel: command.params[0],
msg: command.trailing
- );
+ });
}
},
'CAP': function (command) {
_ = require('lodash');
-var IrcConnection = function (hostname, port, ssl, nick, user, pass) {
+var IrcConnection = function (hostname, port, ssl, nick, user, pass, state) {
var that = this;
events.EventEmitter.call(this);
this.user = user; // Contains users real hostname and address
this.username = this.nick.replace(/[^0-9a-zA-Z\-_.]/, '');
this.password = pass;
+
+ // State object
+ this.state = state;
// IRC connection information
this.irc_host = {hostname: hostname, port: port};
-var util = require('util'),
- IrcConnection = require('./connection.js');
+var util = require('util'),
+ events = require('events'),
+ _ = require('lodash'),
+ IrcConnection = require('./connection.js').IrcConnection;
var State = function (client, save_state) {
events.EventEmitter.call(this);
global.config.restrict_server,
global.config.restrict_server_port,
global.config.restrict_server_ssl,
- command.nick,
+ nick,
user,
- global.config.restrict_server_password);
+ global.config.restrict_server_password,
+ this);
} else {
con = new IrcConnection(
- command.hostname,
- command.port,
- command.ssl,
- command.nick,
+ hostname,
+ port,
+ ssl,
+ nick,
user,
- command.password);
+ pass,
+ this);
}
con_num = this.next_connection++;
});
con.on('error', function (err) {
- console.log('irc_connection error (' + command.hostname + '):', err);
+ console.log('irc_connection error (' + hostname + '):', err);
return callback(err.code, {server: con_num, error: err});
});