Exemple #1
0
        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();
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
 public void RemoveContact(AgentContact contact)
 {
     AgentContactBook.Remove(contact);
 }
Exemple #4
0
 public void AddContact(AgentContact contact)
 {
     AgentContactBook.Add(contact);
 }