From 5743942a7f0c1a6e6ec75bf3ed67ad94a317681d Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Sun, 24 Jul 2022 15:03:13 +0200 Subject: [PATCH] Notify ReactorError before (not after) throwing exception on pending APIs --- FAQ.md | 3 ++- src/Client.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/FAQ.md b/FAQ.md index a00a912..ed096f1 100644 --- a/FAQ.md +++ b/FAQ.md @@ -191,7 +191,8 @@ If Telegram servers decide to shutdown this secondary connection, it's not an is This should be transparent and pending API calls should automatically be resent upon reconnection. You can choose to increase `MaxAutoReconnects` if it happens too often because your Internet connection is unstable. -3) If you reach `MaxAutoReconnects` disconnections, then the **Update** event handler will receive a `ReactorError` object to notify you of the problem. +3) If you reach `MaxAutoReconnects` disconnections, then the **Update** event handler will receive a `ReactorError` object to notify you of the problem, +and pending API calls throw the network IOException. In this case, the recommended action would be to dispose the client and recreate one 4) In case of slow Internet connection or if you break in the debugger for some time, diff --git a/src/Client.cs b/src/Client.cs index b330d0c..c3d0132 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -329,6 +329,7 @@ namespace WTelegram } catch { + OnUpdate(reactorError); lock (_pendingRpcs) // abort all pending requests { foreach (var rpc in _pendingRpcs.Values) @@ -336,7 +337,6 @@ namespace WTelegram _pendingRpcs.Clear(); _bareRpc = null; } - OnUpdate(reactorError); } finally {