private void processUnregisterServiceMessage(AgentMessage message)
        {
            var description = (message.Content as UnregisterServiceAction).AgentDescription;

            Log.Info("Unregistering DFAgentDescription for agent: " + description.AgentId.GetGlobalName() + " from DF: " + AId.GetGlobalName());
            agentDescriptions.Remove(description);
        }
Exemple #2
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);
        }
Exemple #3
0
 override public void ProcessMessage(AgentMessage message)
 {
     if (message.Performative == AgentMessage.PerformativeType.REQUEST)
     {
         if (message.Content.GetType() == typeof(CreateAndStartAgentAction))
         {
             var action = message.Content as CreateAndStartAgentAction;
             AddBehaviour(new CreateAndStartBehaviour(this, action));
         }
     }
 }
Exemple #4
0
        public void PreProcessMessage(AgentMessage message)
        {
            Action <AgentMessage> action;

            if (message.ConversationId != null && messageCallbacks.TryGetValue(message.ConversationId, out action))
            {
                action(message);
                return;
            }
            ProcessMessage(message);
        }
        private void processRegisterServiceMessage(AgentMessage message)
        {
            var description = (message.Content as RegisterServiceAction).AgentDescription;

            Log.Info("Registering DFAgentDescription for agent: " + description.AgentId.GetGlobalName() + " to DF: " + AId.GetGlobalName());
            var indexOfCurrentDescription = agentDescriptions.FindIndex(it => it.AgentId.Equals(description.AgentId));

            if (indexOfCurrentDescription != -1)
            {
                agentDescriptions.RemoveAt(indexOfCurrentDescription);
            }
            agentDescriptions.Add(description);
        }
        private void processSearchForServiceMessage(AgentMessage message)
        {
            var content     = message.Content as SearchForServiceAction;
            var description = content.AgentDescription;
            var agentId     = content.AgentId;

            var foundAgentDescriptions = agentDescriptions
                                         .FindAll(agentDescription => validateAgentDescription(agentDescription, description))
                                         .FindAll(agentDescription => agentDescription.AgentId != agentId);

            var concept = new AgentDescriptionListConcept(foundAgentDescriptions);
            var reply   = message.Reply(AgentMessage.PerformativeType.INFORM);

            reply.Content = concept;
            Send(reply);
        }
 override public void ProcessMessage(AgentMessage message)
 {
     if (message.Performative == AgentMessage.PerformativeType.REQUEST)
     {
         if (message.Content.GetType() == typeof(RegisterServiceAction))
         {
             processRegisterServiceMessage(message);
         }
         else if (message.Content.GetType() == typeof(UnregisterServiceAction))
         {
             processUnregisterServiceMessage(message);
         }
         else if (message.Content.GetType() == typeof(SearchForServiceAction))
         {
             processSearchForServiceMessage(message);
         }
     }
 }
Exemple #8
0
        private IEnumerator AsyncCreate(string name, string typeName, object[] args, string containerID)
        {
            // Wait until container is registered in main container for agent creation operations
            while (!IsStarted)
            {
                yield return(new WaitForEndOfFrame());
            }

            // If agent's container's ID was not provided, assume it is current container's ID
            if (containerID == null)
            {
                containerID = ID;
            }
            CreateAndStartAgentAction action =
                new CreateAndStartAgentAction(name, typeName, containerID, args);
            AgentMessage message = new AgentMessage(AgentMessage.PerformativeType.REQUEST);

            message.Content  = action;
            message.Receiver = new AgentId(AgentManager.LOCAL_NAME, ID);
            CommunicationChannel.PostMessage(message);
            yield return(null);
        }
Exemple #9
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);
        }
Exemple #10
0
 public virtual void SendMessage(AgentMessage message)
 {
     communicationChannels.Find(channel => channel.AId.Equals(message.Receiver)).PostMessage(message);
 }
Exemple #11
0
 public virtual void Send(AgentMessage message)
 {
     message.Sender = AId;
     container.CommunicationChannel.PostMessage(message);
 }
Exemple #12
0
        // Messaging

        public void PostMessage(AgentMessage message)
        {
            messageQueue.Enqueue(message);
        }
Exemple #13
0
 public virtual void ProcessMessage(AgentMessage message)
 {
 }