Пример #1
0
 public void Unregister(CommunicationAgent communicationAgent)
 {
     Console.WriteLine("Unregister ", communicationAgent.AgentId);
     lock (agents)
     {
         agents.Remove(communicationAgent.AgentId);
     }
 }
Пример #2
0
 private void sendMessage(Message msg)
 {
     lock (agents)
     {
         CommunicationAgent a = agents[msg.To];
         a.ReceiveMessage(msg);
     }
 }
Пример #3
0
        public string Register(CommunicationAgent communicationAgent, AgentType type)
        {
            Console.WriteLine("Register ", type.ToString());
            String agentId = null;

            lock (agents)
            {
                switch (type)
                {
                case AgentType.Client: agentId = @"C" + last_client; last_client++; break;

                case AgentType.Seller: agentId = @"S" + last_seller; last_seller++; break;
                }
                agents[agentId] = communicationAgent;
            }
            return(agentId);
        }