Fix client 'connect' event being send when using tls.

With `tls.connect()` the socket connect event is 'secureConnect' instead
of 'connect'.
This commit is contained in:
Trent Mick 2012-04-13 15:42:58 -07:00
parent 34b9d7f8fd
commit e825615d9e
1 changed files with 16 additions and 17 deletions

View File

@ -627,7 +627,22 @@ Client.prototype.connect = function connect(callback) {
var self = this;
var timer = false;
c = proto.connect(opts.port, opts.host);
c = proto.connect(opts.port, opts.host, function () {
if (timer)
clearTimeout(timer);
assert.ok(c.ldap);
c.ldap.id += c.fd ? (':' + c.fd) : '';
if (log.trace())
log.trace('%s connect event', c.ldap.id);
self.connection = c;
self.emit('connect', c);
return (typeof (callback) === 'function' ? callback(null, c) : false);
});
if (this.connectTimeout) {
timer = setTimeout(function () {
@ -658,22 +673,6 @@ Client.prototype.connect = function connect(callback) {
})
};
c.on('connect', function () {
if (timer)
clearTimeout(timer);
assert.ok(c.ldap);
c.ldap.id += c.fd ? (':' + c.fd) : '';
if (log.trace())
log.trace('%s connect event', c.ldap.id);
self.connection = c;
self.emit('connect', c);
return (typeof (callback) === 'function' ? callback(null, c) : false);
});
c.on('end', function () {
if (log.trace())