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