Try to fix the reconnection system, but it's not working right.

This commit is contained in:
Starbeamrainbowlabs 2018-12-02 16:47:23 +00:00
parent 19be6f8425
commit 216cd6d479
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
1 changed files with 13 additions and 7 deletions

View File

@ -107,14 +107,20 @@ namespace RhinoReminds
private void errorHandler(object sender, S22.Xmpp.Im.ErrorEventArgs e)
{
Console.Error.WriteLine($"Error {e.Reason}: {e.Exception}");
Console.Error.WriteLine($"Reconnecting in {TimeSpan.FromSeconds(nextBackoffDelay).ToString()}.");
Console.Error.WriteLine($"[Error] {e.Reason}: {e.Exception}");
if(!client.Connected)
{
Console.Error.WriteLine($"[Error/Handler] Reconnecting in {TimeSpan.FromSeconds(nextBackoffDelay).ToString()}.");
Thread.Sleep(nextBackoffDelay * 1000);
Console.WriteLine("[Error/Handler] Attempting to reconnect to the server");
Task.Delay(nextBackoffDelay * 1000).Wait();
if (!connect().Result)
nextBackoffDelay = (int)Math.Ceiling(nextBackoffDelay * backoffDelayMultiplier);
else
nextBackoffDelay = defaultBackoffDelay;
}
}
private void messageHandlerRoot(object sender, MessageEventArgs eventArgs)