public bool Run(BotDescriptor botDesc) { GC.Collect(); GC.WaitForPendingFinalizers(); try { BotManager manager = FindBotManager(botDesc); if (manager != null) { manager.StopBots(); manager.StartBots(); return true; } BotManager botManager = new BotManager(botDesc); botManager.StartBots(); FBotManagers.Add(botManager); } catch (Exception e) { AppContext.WriteLog(e.Message); return false; } return true; }
public Bot(BotManager manager,BotDescriptor BotDesc, int BotId) { FBotId = BotId; FManager = manager; FBotDesc = BotDesc; FBufferManager = new BufferManager(); FBufferManager.Initialize(100, 100); FPacketSpliter = new PacketSpliter(); FPacketSpliter.OnPacket += OnPacket; FConnArg = new SocketAsyncEventArgs(); FConnArg.Completed += new EventHandler<SocketAsyncEventArgs>(IO_Completed); FConnArg.UserToken = this; FConnArg.RemoteEndPoint = FBotDesc.Host; FDisconnArg = new SocketAsyncEventArgs(); FDisconnArg.Completed += new EventHandler<SocketAsyncEventArgs>(IO_Completed); FDisconnArg.UserToken = this; FDisconnArg.DisconnectReuseSocket = true; FSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); FTimer = new Timer(OnTimer); }
public void Stop(BotDescriptor botDesc) { try { BotManager manager = FindBotManager(botDesc); if(manager != null) { manager.StopBots(); } } catch (Exception e) { AppContext.WriteLog(e.Message); } GC.Collect(); GC.WaitForPendingFinalizers(); }
public BotCommand(BotDescriptor bot, string name) { BotDesc = bot; CommandName = name; Parameters = new List<Parameter>(); }
BotManager FindBotManager(BotDescriptor bot) { return FBotManagers.Find((manager) => { return manager.BotDesc == bot;}); }
/// <summary> /// OnBotsToExecutedSelectedChanged /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnBotsToExecutedSelectedChanged(object sender, EventArgs e) { selectedBotToExecute = listBoxBotsToExecute.SelectedItem as BotDescriptor; propertyGridBotParameters.SelectedObject = selectedBotToExecute.Parameters; }
public BotManager(BotDescriptor BotDesc) { FBotDesc = BotDesc; }