enable auto recovery of bot

This commit is contained in:
Madpeter 2024-07-03 23:30:55 +01:00
parent a5c58c2363
commit f7dd65781f
2 changed files with 16 additions and 0 deletions

View file

@ -145,6 +145,7 @@ namespace SecondBotEvents.Commands
[ReturnHints("ok")] [ReturnHints("ok")]
public object Logoff() public object Logoff()
{ {
master.BotClient.flagLogoutExpected();
GetClient().Network.BeginLogout(); GetClient().Network.BeginLogout();
return BasicReply("ok"); return BasicReply("ok");
} }

View file

@ -15,6 +15,12 @@ namespace SecondBotEvents.Services
public GridClient client = null; public GridClient client = null;
public BasicConfig basicCfg = null; public BasicConfig basicCfg = null;
protected bool LogoutExpected = false;
public void flagLogoutExpected()
{
LogoutExpected = true;
}
protected bool ExitBot = false; protected bool ExitBot = false;
protected Timer AutoRestartLoginTimer; protected Timer AutoRestartLoginTimer;
@ -78,6 +84,15 @@ namespace SecondBotEvents.Services
protected void BotDisconnected(object o, DisconnectedEventArgs e) protected void BotDisconnected(object o, DisconnectedEventArgs e)
{ {
LogFormater.Info("Client service ~ Network disconnected: " + e.Message); 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) protected void BotLoginStatus(object o, LoginProgressEventArgs e)