GramJs: Do not reconnect after manual disconnect (#1217)
This commit is contained in:
parent
78ad0fbd48
commit
0d0b6e7df6
@ -81,6 +81,12 @@ class MTProtoSender {
|
|||||||
this._isMainSender = args.isMainSender;
|
this._isMainSender = args.isMainSender;
|
||||||
this._onConnectionBreak = args.onConnectionBreak;
|
this._onConnectionBreak = args.onConnectionBreak;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether we disconnected ourself or telegram did it.
|
||||||
|
*/
|
||||||
|
this.userDisconnected = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the user has explicitly connected or disconnected.
|
* Whether the user has explicitly connected or disconnected.
|
||||||
*
|
*
|
||||||
@ -192,6 +198,7 @@ class MTProtoSender {
|
|||||||
* all pending requests, and closes the send and receive loops.
|
* all pending requests, and closes the send and receive loops.
|
||||||
*/
|
*/
|
||||||
async disconnect() {
|
async disconnect() {
|
||||||
|
this.userDisconnected = true;
|
||||||
await this._disconnect();
|
await this._disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,8 +385,11 @@ class MTProtoSender {
|
|||||||
body = await this._connection.recv();
|
body = await this._connection.recv();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// this._log.info('Connection closed while receiving data');
|
// this._log.info('Connection closed while receiving data');
|
||||||
this._log.warn('Connection closed while receiving data');
|
/** when the server disconnects us we want to reconnect */
|
||||||
this.reconnect();
|
if (!this.userDisconnected) {
|
||||||
|
this._log.warn('Connection closed while receiving data');
|
||||||
|
this.reconnect();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user