Skip to content

Commit

Permalink
Merge pull request #333 from martynsmith/jirwin/update-travis
Browse files Browse the repository at this point in the history
fix(travis): Add node 0.12 and iojs to travis.
  • Loading branch information
jirwin committed Apr 15, 2015
2 parents 1d5127d + c6d4262 commit 56f0ff2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: node_js
node_js:
- "0.12"
- "0.10"
- "iojs"
before_install:
- sudo apt-get -y install libicu-dev
- npm install -g npm
Expand Down
47 changes: 18 additions & 29 deletions lib/irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,21 @@ Client.prototype.chanData = function(name, create) {
return this.chans[key];
};

Client.prototype._connectionHandler = function() {
if (this.opt.webirc.ip && this.opt.webirc.pass && this.opt.webirc.host) {
this.send('WEBIRC', this.opt.webirc.pass, this.opt.userName, this.opt.webirc.host, this.opt.webirc.ip);
}
if (this.opt.password) {
this.send('PASS', this.opt.password);
}
if (this.opt.debug)
util.log('Sending irc NICK/USER');
this.send('NICK', this.opt.nick);
this.nick = this.opt.nick;
this.send('USER', this.opt.userName, 8, '*', this.opt.realName);
this.emit('connect');
};

Client.prototype.connect = function(retryCount, callback) {
if (typeof (retryCount) === 'function') {
callback = retryCount;
Expand Down Expand Up @@ -686,25 +701,15 @@ Client.prototype.connect = function(retryCount, callback) {
self.conn.authorizationError === 'CERT_HAS_EXPIRED') {
util.log('Connecting to server with expired certificate');
}
if (self.opt.webirc.ip && self.opt.webirc.pass && self.opt.webirc.host) {
self.send('WEBIRC', self.opt.webirc.pass, self.opt.userName, self.opt.webirc.host, self.opt.webirc.ip);
}
if (self.opt.password) {
self.send('PASS', self.opt.password);
}
if (self.opt.debug)
util.log('Sending irc NICK/USER');
self.send('NICK', self.opt.nick);
self.nick = self.opt.nick;
self.send('USER', self.opt.userName, 8, '*', self.opt.realName);
self.emit('connect');

self._connectionHandler();
} else {
// authorization failed
util.log(self.conn.authorizationError);
}
});
} else {
self.conn = net.createConnection(connectionOpts);
self.conn = net.createConnection(connectionOpts, self._connectionHandler.bind(self));
}
self.conn.requestedDisconnect = false;
self.conn.setTimeout(0);
Expand All @@ -713,22 +718,6 @@ Client.prototype.connect = function(retryCount, callback) {
self.conn.setEncoding('utf8');
}

self.conn.addListener('connect', function() {
if (self.opt.sasl) {
// see http://ircv3.atheme.org/extensions/sasl-3.1
self.send('CAP REQ', 'sasl');
}
if (self.opt.webirc.ip && self.opt.webirc.pass && self.opt.webirc.host) {
self.send('WEBIRC', self.opt.webirc.pass, self.opt.userName, self.opt.webirc.host, self.opt.webirc.ip);
} else if (self.opt.password) {
self.send('PASS', self.opt.password);
}
self.send('NICK', self.opt.nick);
self.nick = self.opt.nick;
self.send('USER', self.opt.userName, 8, '*', self.opt.realName);
self.emit('connect');
});

var buffer = new Buffer('');

self.conn.addListener('data', function(chunk) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"irc-colors": "^1.1.0"
},
"optionalDependencies": {
"iconv": "~2.1.4",
"iconv": "~2.1.6",
"node-icu-charset-detector": "0.1.0"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ var MockIrcd = function(port, encoding, isSecure) {

this.server = connectionClass.createServer(options, function(c) {
c.on('data', function(data) {
var msg = data.toString(self.encoding);
self.incoming = self.incoming.concat(msg.split('\r\n'));
var msg = data.toString(self.encoding).split('\r\n').filter(function(m) { return m; });
self.incoming = self.incoming.concat(msg);
});

self.on('send', function(data) {
Expand All @@ -56,7 +56,7 @@ MockIrcd.prototype.close = function() {
};

MockIrcd.prototype.getIncomingMsgs = function() {
return this.incoming.filter(function(msg) { return msg; });
return this.incoming;
};

var fixtures = require('./data/fixtures');
Expand Down

0 comments on commit 56f0ff2

Please sign in to comment.