Move client.connect into public API
In cases where a reconnect-enabled client has been manually disconnected via unbind, it may be desirable to initiate a reconnect without incurring other client actions.
This commit is contained in:
parent
59bebe537b
commit
abdd4890e5
|
@ -343,7 +343,7 @@ function Client(options) {
|
||||||
|
|
||||||
this.socket = null;
|
this.socket = null;
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
this._connect();
|
this.connect();
|
||||||
}
|
}
|
||||||
util.inherits(Client, EventEmitter);
|
util.inherits(Client, EventEmitter);
|
||||||
module.exports = Client;
|
module.exports = Client;
|
||||||
|
@ -861,13 +861,11 @@ Client.prototype.destroy = function destroy(err) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///--- Private API
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiate LDAP connection.
|
* Initiate LDAP connection.
|
||||||
*/
|
*/
|
||||||
Client.prototype._connect = function _connect() {
|
Client.prototype.connect = function connect() {
|
||||||
if (this.connecting) {
|
if (this.connecting || this.connected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -1103,6 +1101,10 @@ Client.prototype._connect = function _connect() {
|
||||||
retry.backoff();
|
retry.backoff();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///--- Private API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush queued requests out to the socket.
|
* Flush queued requests out to the socket.
|
||||||
*/
|
*/
|
||||||
|
@ -1153,7 +1155,7 @@ Client.prototype._onClose = function _onClose(had_err) {
|
||||||
// Automatically fire reconnect logic if the socket was closed for any reason
|
// Automatically fire reconnect logic if the socket was closed for any reason
|
||||||
// other than a user-initiated unbind.
|
// other than a user-initiated unbind.
|
||||||
if (this.reconnect && !this.unbound) {
|
if (this.reconnect && !this.unbound) {
|
||||||
this._connect();
|
this.connect();
|
||||||
}
|
}
|
||||||
this.unbound = false;
|
this.unbound = false;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1218,7 +1220,7 @@ Client.prototype._send = function _send(message,
|
||||||
}
|
}
|
||||||
// Initiate reconnect if needed
|
// Initiate reconnect if needed
|
||||||
if (this.reconnect) {
|
if (this.reconnect) {
|
||||||
this._connect();
|
this.connect();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue