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

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)