Ver Fonte

Return false on connect failure.

Painor há 1 ano atrás
pai
commit
eab0bdb7d3

+ 1 - 1
gramjs/Version.ts

@@ -1 +1 @@
-export const version = "2.19.3";
+export const version = "2.19.5";

+ 2 - 1
gramjs/client/TelegramClient.ts

@@ -1407,7 +1407,7 @@ export class TelegramClient extends TelegramBaseClient {
                 _updateLoop(this);
                 this._loopStarted = true;
             }
-            return;
+            return false;
         }
         this.session.setAuthKey(this._sender.authKey);
         this.session.save();
@@ -1426,6 +1426,7 @@ export class TelegramClient extends TelegramBaseClient {
         }
         this._connectedDeferred.resolve();
         this._isSwitchingDc = false;
+        return true;
     }
     //endregion
     // region Working with different connections/Data Centers

+ 5 - 2
gramjs/network/MTProtoSender.ts

@@ -107,6 +107,7 @@ export class MTProtoSender {
     private _connectMutex: Mutex;
     private _cancelSend: boolean;
     cancellableRecvLoopPromise?: CancellablePromise<any>;
+    private _finishedConnecting: boolean;
 
     /**
      * @param authKey
@@ -117,6 +118,7 @@ export class MTProtoSender {
             ...MTProtoSender.DEFAULT_OPTIONS,
             ...opts,
         };
+        this._finishedConnecting = false;
         this._cancelSend = false;
         this._connection = undefined;
         this._log = args.logger;
@@ -249,7 +251,7 @@ export class MTProtoSender {
         }
         this.isConnecting = true;
         this._connection = connection;
-
+        this._finishedConnecting = false;
         for (let attempt = 0; attempt < this._retries; attempt++) {
             try {
                 await this._connect();
@@ -261,6 +263,7 @@ export class MTProtoSender {
                         )
                     );
                 }
+                this._finishedConnecting = true;
                 break;
             } catch (err) {
                 if (this._updateCallback && attempt === 0) {
@@ -282,7 +285,7 @@ export class MTProtoSender {
         }
         this.isConnecting = false;
 
-        return true;
+        return this._finishedConnecting;
     }
 
     isConnected() {

+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "telegram",
-  "version": "2.19.4",
+  "version": "2.19.6",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "telegram",
-      "version": "2.19.4",
+      "version": "2.19.6",
       "license": "MIT",
       "dependencies": {
         "@cryptography/aes": "^0.1.1",

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "telegram",
-  "version": "2.19.4",
+  "version": "2.19.6",
   "description": "NodeJS/Browser MTProto API Telegram client library,",
   "main": "index.js",
   "types": "index.d.ts",