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.connected = false;
|
||||
this._connect();
|
||||
this.connect();
|
||||
}
|
||||
util.inherits(Client, EventEmitter);
|
||||
module.exports = Client;
|
||||
|
@ -861,13 +861,11 @@ Client.prototype.destroy = function destroy(err) {
|
|||
};
|
||||
|
||||
|
||||
///--- Private API
|
||||
|
||||
/**
|
||||
* Initiate LDAP connection.
|
||||
*/
|
||||
Client.prototype._connect = function _connect() {
|
||||
if (this.connecting) {
|
||||
Client.prototype.connect = function connect() {
|
||||
if (this.connecting || this.connected) {
|
||||
return;
|
||||
}
|
||||
var self = this;
|
||||
|
@ -1103,6 +1101,10 @@ Client.prototype._connect = function _connect() {
|
|||
retry.backoff();
|
||||
};
|
||||
|
||||
|
||||
|
||||
///--- Private API
|
||||
|
||||
/**
|
||||
* 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
|
||||
// other than a user-initiated unbind.
|
||||
if (this.reconnect && !this.unbound) {
|
||||
this._connect();
|
||||
this.connect();
|
||||
}
|
||||
this.unbound = false;
|
||||
return false;
|
||||
|
@ -1218,7 +1220,7 @@ Client.prototype._send = function _send(message,
|
|||
}
|
||||
// Initiate reconnect if needed
|
||||
if (this.reconnect) {
|
||||
this._connect();
|
||||
this.connect();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue