Exemplo n.º 1
0
 public void Unregister(CommunicationAgent communicationAgent)
 {
     Console.WriteLine("Unregister ", communicationAgent.AgentId);
     lock (agents)
     {
         agents.Remove(communicationAgent.AgentId);
     }
 }
Exemplo n.º 2
0
 private void sendMessage(Message msg)
 {
     lock (agents)
     {
         CommunicationAgent a = agents[msg.To];
         a.ReceiveMessage(msg);
     }
 }
Exemplo n.º 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);
        }