/*********************************************************************/ /* */ /* AgentService Framework */ /* www.agentservice.it */ /* */ /* Copyright (C) 2007 l.i.d.o. - DIST, University of Genoa, Italy */ /* GNU Lesser General Public License */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation, */ /* version 2.1 of the License. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public */ /* License along with this library; if not, write to the */ /* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ /* Boston, MA 02111-1307, USA. */ /* */ /*********************************************************************/ using System; using AgentService.Platform.AMS; using AgentService.Platform.MTS; using AgentService.Agent.Runtime; namespace AgentService.Platform.Modules { /// /// Delegate MessageEventHandler. Call-back signature for /// methods used to handle messages sent to core agents. /// public delegate void MessageEventHandler(AgentMessage message); /// /// Interface IMessagingModule. Defines the /// basic functionalities that each concrete /// messaging subsystem must implement in order /// to be plugged into the AgentService platform /// public interface IMessagingModule : IPlatformModule { /// /// Creates a message queue owned by the given agent. /// /// agent identifier of the agent that owns the queue /// true if the queue has been successfully created bool CreateAgentQueue(AID aid); /// /// Removes a message queue owned by the given agent. /// /// agent identifier of the agent that owns the queue /// true if the queue has been successfully removed bool RemoveAgentQueue(AID aid); /// /// Checks whether a queue has messages. /// /// agent identifier of the owner of the queue /// true if the queue has messages bool HasMessages(AID aid); /// /// Sends a message to an agent. /// /// message /// true if the message has been successfully sent bool SendMessage(AgentMessage message); /// /// Receives a message pops it from the queue. /// /// agent identifier of the agent that owns the queue /// the first message available in the queue AgentMessage ReceiveMessage(AID aid); /// /// Retrieves all the messages and leaves them in the queue. /// /// agent identifier of the agent that owns the queue /// message filter, set this parameter to null if you do not want to apply any filter /// maximum number of element to retrieve place, set this value to 0 or less /// to retrieve all the messages in the queue which satisfy the filter /// if true remove the message from the queue /// the collection of messages retrieved from the queue AgentMessageCollection GetMessages(AID aid, MessageFilter filter, int max, bool bRemove); /// /// Same as GetMessages but returns just the first message satisfying the filter. /// This method provide a fast implementation for retrieving one single implementation /// and also provide the implementation of the Peek verb. /// /// agent identifier of the agent that owns the queue /// message filter, null if no filters are required /// if true removes the message from the queue /// the first message in the queue or null AgentMessage GetMessage(AID aid, MessageFilter filter, bool bRemove); /// /// Creates a client of the messaging module for the given agent. /// /// agent identifier. /// a messaging client for the given agent, null if the module does not provide a custom client. IMsgClient CreateClient(AID aid); /// /// Returns true if the messaging module provides a custom client. /// bool HasClient { get; } /// /// Removes the given message from the queue. /// /// agent identifier of the agent that owns the queue /// message to be destroyed /// true if message is successfully removed bool RemoveMessage(AID aid, AgentMessage message); /// /// Removes all the messages in each agent queue /// /// True if succeds void ClearAllMessages(); /// /// Removes all the messages from the queue of the given agent /// /// AID of the agent /// True if succeds bool ClearAllMessages(AID aid); /// /// Gets a string containing information about the address of the platform, e.g.: AgentService@10.0.0.1:4989 /// string TransportProfile { get; } /// /// Raises every time a message is sent to the /// AMS queue. /// event MessageEventHandler NotifyAMS; /// /// Raises every time a message is sent to the /// MTS queue. /// event MessageEventHandler NotifyMTS; /// /// Raises every time a message is sent to the /// DF queue. /// event MessageEventHandler NotifyDF; } }