diff --git a/SecondBotEvents/Commands/Self.cs b/SecondBotEvents/Commands/Self.cs index b8e6841..baac4e9 100644 --- a/SecondBotEvents/Commands/Self.cs +++ b/SecondBotEvents/Commands/Self.cs @@ -145,6 +145,7 @@ namespace SecondBotEvents.Commands [ReturnHints("ok")] public object Logoff() { + master.BotClient.flagLogoutExpected(); GetClient().Network.BeginLogout(); return BasicReply("ok"); } diff --git a/SecondBotEvents/Services/BotClientService.cs b/SecondBotEvents/Services/BotClientService.cs index 46da80a..d06df79 100644 --- a/SecondBotEvents/Services/BotClientService.cs +++ b/SecondBotEvents/Services/BotClientService.cs @@ -15,6 +15,12 @@ namespace SecondBotEvents.Services public GridClient client = null; public BasicConfig basicCfg = null; + protected bool LogoutExpected = false; + public void flagLogoutExpected() + { + LogoutExpected = true; + } + protected bool ExitBot = false; protected Timer AutoRestartLoginTimer; @@ -78,6 +84,15 @@ namespace SecondBotEvents.Services protected void BotDisconnected(object o, DisconnectedEventArgs e) { LogFormater.Info("Client service ~ Network disconnected: " + e.Message); + if (LogoutExpected == false) + { + AutoRestartLoginTimer = new Timer(); + AutoRestartLoginTimer.Interval = 75 * 1000; + AutoRestartLoginTimer.AutoReset = false; + AutoRestartLoginTimer.Elapsed += RestartTimer; + LogFormater.Info("Client service ~ Unexpected disconnect (starting reconnect timer for 75s)"); + return; + } } protected void BotLoginStatus(object o, LoginProgressEventArgs e)