Go back to disconnecting bots in parallel since serially is too slow.
However, disconnecting now halts any current connection, with the possible exception of the single currently connecting bot.bullet-2.82
parent
fcc665a567
commit
0e71e3889c
|
@ -349,7 +349,7 @@ namespace pCampBot
|
||||||
|
|
||||||
foreach (Bot bot in botsToConnect)
|
foreach (Bot bot in botsToConnect)
|
||||||
{
|
{
|
||||||
if (DisconnectingBots)
|
if (!ConnectingBots)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output(
|
MainConsole.Instance.Output(
|
||||||
"[BOT MANAGER]: Aborting bot connection due to user-initiated disconnection");
|
"[BOT MANAGER]: Aborting bot connection due to user-initiated disconnection");
|
||||||
|
@ -629,6 +629,8 @@ namespace pCampBot
|
||||||
botsToDisconnectCount = Math.Min(botsToDisconnectCount, connectedBots.Count);
|
botsToDisconnectCount = Math.Min(botsToDisconnectCount, connectedBots.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisconnectingBots = true;
|
||||||
|
|
||||||
Thread disconnectBotThread = new Thread(o => DisconnectBotsInternal(connectedBots, botsToDisconnectCount));
|
Thread disconnectBotThread = new Thread(o => DisconnectBotsInternal(connectedBots, botsToDisconnectCount));
|
||||||
|
|
||||||
disconnectBotThread.Name = "Bots disconnection thread";
|
disconnectBotThread.Name = "Bots disconnection thread";
|
||||||
|
@ -637,7 +639,7 @@ namespace pCampBot
|
||||||
|
|
||||||
private void DisconnectBotsInternal(List<Bot> connectedBots, int disconnectCount)
|
private void DisconnectBotsInternal(List<Bot> connectedBots, int disconnectCount)
|
||||||
{
|
{
|
||||||
DisconnectingBots = true;
|
ConnectingBots = false;
|
||||||
|
|
||||||
MainConsole.Instance.OutputFormat("Disconnecting {0} bots", disconnectCount);
|
MainConsole.Instance.OutputFormat("Disconnecting {0} bots", disconnectCount);
|
||||||
|
|
||||||
|
@ -652,7 +654,7 @@ namespace pCampBot
|
||||||
|
|
||||||
if (thisBot.ConnectionState == ConnectionState.Connected)
|
if (thisBot.ConnectionState == ConnectionState.Connected)
|
||||||
{
|
{
|
||||||
thisBot.Disconnect();
|
ThreadPool.QueueUserWorkItem(o => thisBot.Disconnect());
|
||||||
disconnectedBots++;
|
disconnectedBots++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue