public Agent() { AgentContactBook = new AgentContactBook(this); LoadConfig("config.xml"); IP = IPHelper.GetLocalIPAddress(); Commands = new Dictionary <string, Command>(); PendingCommands = new Dictionary <string, Command>(); PackageControl = new PackageControl(); ackReceivers = new List <IAckReceiver>(); Receiver = new Receiver(Port); Receiver.OnReceive += Receiver_OnReceive; tickThread = new Thread(TicTac); tickThread.Start(); }
private void LoadConfig(string config_path) { Config = ConfigData.Deserialize(config_path); var date = DateTime.Now; if (Config.Port == 0) { Port = new Random(date.Minute + date.Second + date.Millisecond).Next(Config.PortFrom, Config.PortTo); Debug.Log(string.Format("Random generated port {0}", Port), Logger.Level.Warning); } else { Port = Config.Port; } TAG = Config.Tag; for (int i = 0; i < Config.Contacts.Count; i++) { AgentContact c = Config.Contacts[i]; AgentContactBook.Add(c); } }
public void RemoveContact(AgentContact contact) { AgentContactBook.Remove(contact); }
public void AddContact(AgentContact contact) { AgentContactBook.Add(contact); }