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