|
fipa_acl
1.4
|
This library provides a statemachine to monitor a message flow based on performatives. The conversation monitor is capable of monitoring the conversation based on the protocol specified in the messages. There are scxml documents specifying how these protocols are defined. Protocols may contain subprotocols, which is partially supported. More...
#include <conversation_monitor.h>
Public Member Functions | |
| ConversationMonitor (const AgentID &self, const std::string &protocolDirectory="") | |
| virtual | ~ConversationMonitor () |
| ConversationPtr | updateConversation (const fipa::acl::ACLMessage &msg) |
| ConversationPtr | startConversation (const std::string &topic) |
| bool | removeConversation (const fipa::acl::ConversationID &conversationId) |
| ConversationPtr | getConversation (const fipa::acl::ConversationID &conversationId) |
| ConversationPtr | getOrCreateConversation (const fipa::acl::ConversationID &conversationId) |
| void | cleanup () |
| std::vector< fipa::acl::ConversationID > | getActiveConversations () |
This library provides a statemachine to monitor a message flow based on performatives. The conversation monitor is capable of monitoring the conversation based on the protocol specified in the messages. There are scxml documents specifying how these protocols are defined. Protocols may contain subprotocols, which is partially supported.
The following sections provide an overview how to use the monitor and which constraints it has.
To verify a conversation, one could do the following:
ConversationMonitor monitor (selfAgentId);
ConversationPtr convPtr = monitor.startConversation("myTopic");
ACLMessage myMsg(ACLMessage::INFORM);
// Continue creating message, e.g. using inform protocol
myMsg.setProtocol("inform");
// ...
convPtr->update(myMsg);
if(convPtr->hasEnded())
{
// ...
}
If the conversation's protocol has subprotocols, at the point before starting a subProtocol, this becomes necessary:
// ... convPtr->setNumberOfSubConversations(n); // where n is the number of subconversations the agent plans to start.
If one wishes to be notified of changes to a conversation, one can use the following after obtaining a ConversationPtr:
ConversationObserverPtr observer(new ConversationObserver());
convPtr->addObserver(observer);
// Method A:
conversation::Event event = observer->waitForNextEvent();
// ...
// Method B:
conversation::Event event;
if(observer->hasEvents() && observer->getNextEvent(event))
{
// ...
}
At the moment, to handle subprotocols correctly a few constraints apply. If the agents to not obey these rules, the monitoring will fail.
Definition at line 75 of file conversation_monitor.h.
| fipa::acl::ConversationMonitor::ConversationMonitor | ( | const AgentID & | self, |
| const std::string & | protocolDirectory = "" |
||
| ) |
Construct the conversation monitor using the system configuration object which for example holds the name of the agent
| self | AgendID of the current agent |
| protocolDirectory | Directory of interaction protocols |
Definition at line 7 of file conversation_monitor.cpp.
|
virtual |
| void fipa::acl::ConversationMonitor::cleanup | ( | ) |
Cleanup all conversations, that ended
Definition at line 93 of file conversation_monitor.cpp.
| std::vector< fipa::acl::ConversationID > fipa::acl::ConversationMonitor::getActiveConversations | ( | ) |
Get a list of conversation ids of all active conversations
Definition at line 125 of file conversation_monitor.cpp.
| ConversationPtr fipa::acl::ConversationMonitor::getConversation | ( | const fipa::acl::ConversationID & | conversationId | ) |
Get conversation associated with a certain conversation id User has to verify that id of conversation is unqual to an empty string
Definition at line 66 of file conversation_monitor.cpp.
| ConversationPtr fipa::acl::ConversationMonitor::getOrCreateConversation | ( | const fipa::acl::ConversationID & | conversationId | ) |
Get conversation associated with a certain conversation id or create a new one if it does not exist yet
Definition at line 78 of file conversation_monitor.cpp.
| bool fipa::acl::ConversationMonitor::removeConversation | ( | const fipa::acl::ConversationID & | conversationId | ) |
Close a conversation with the provided conversationId
Definition at line 50 of file conversation_monitor.cpp.
| ConversationPtr fipa::acl::ConversationMonitor::startConversation | ( | const std::string & | topic | ) |
Start a conversation without a message - this is required for internal requests refer to OutgoingMessageHandler::operator()() The id will be automatically generated at construction time of Conversation and extended by the topic if required
| topic | Topic to add to the automatically generated conversation id |
Definition at line 57 of file conversation_monitor.cpp.
| ConversationPtr fipa::acl::ConversationMonitor::updateConversation | ( | const fipa::acl::ACLMessage & | msg | ) |
When an internal message has been generated as a response or as an initiation of a conversation update the conversation monitor using this function
| the | outgoing message |
| InvalidOperation | if conversation does not exist this message |
| ProtocolError | if conversation cannot consume the message due to an invalid protocol flow |
Definition at line 21 of file conversation_monitor.cpp.
1.8.13