Esempio n. 1
0
        public static void UnregisterService(Agent agent, AgentId dfAgentId, DFAgentDescription dFAgentDescription)
        {
            AgentMessage message = new AgentMessage(AgentMessage.PerformativeType.REQUEST);

            message.Receiver = dfAgentId;
            message.Content  = new UnregisterServiceAction(dFAgentDescription);
            agent.Send(message);
        }
Esempio n. 2
0
        public static void RequestSearch(Agent agent, AgentId dfAgentId, DFAgentDescription dFAgentDescription, Action <AgentDescriptionListConcept> callback)
        {
            AgentMessage message = new AgentMessage(AgentMessage.PerformativeType.REQUEST);

            message.Receiver       = dfAgentId;
            message.Content        = new SearchForServiceAction(agent.AId, dFAgentDescription);
            message.ConversationId = StringUtils.GenerateRandomString(15);
            agent.Send(message);

            Action <AgentMessage> messageCallback = delegate(AgentMessage receivedMessage) {
                if (receivedMessage.ConversationId == message.ConversationId)
                {
                    if (receivedMessage.Content.GetType() == typeof(AgentDescriptionListConcept))
                    {
                        callback(receivedMessage.Content as AgentDescriptionListConcept);
                    }
                }
                agent.UnregisterMessageCallback(message.ConversationId);
            };

            agent.RegisterMessageCallback(message.ConversationId, messageCallback);
        }
Esempio n. 3
0
 public Agent GetAgent(AgentId id)
 {
     return(agents.Find(agent => agent.AId.Equals(id)));
 }