fipa_services
Public Member Functions | List of all members
fipa::services::message_transport::MessageTransport Class Reference

Service responsible for handling FIPA message and managing the forwarding and relaying. More...

#include <MessageTransport.hpp>

Public Member Functions

 MessageTransport (const fipa::acl::AgentID &id, ServiceDirectory::Ptr serviceDirectory)
 Constructor for MessageTransport. More...
 
fipa::acl::AgentID getAgentID () const
 
void configure (const std::vector< transports::Configuration > &configurations)
 
void activateTransports (const std::vector< std::string > &transports)
 
void activateTransports (transports::Transport::Type flags)
 
void activateTransport (transports::Transport::Type type)
 
std::vector< fipa::services::ServiceLocationgetTransportEndpoints () const
 
void handle (fipa::acl::Letter &msg)
 
void handleError (const fipa::acl::Letter &msg) const
 
void registerMessageTransport (const std::string &id, MessageTransportHandler handler)
 
void deregisterMessageTransport (const std::string &id)
 
void modifyMessageTransport (const std::string &id, MessageTransportHandler handler)
 
bool handleInternalCommunication (const fipa::acl::Letter &letter)
 
void setInternalMessageRepresentationType (const fipa::acl::representation::Type &representation)
 
fipa::acl::representation::Type getInternalMessageRepresentationType () const
 
void trigger ()
 
std::string getServiceSignature () const
 
void addAcceptedServiceSignature (const std::string &signature)
 
ServiceDirectory::Ptr getServiceDirectory ()
 
void registerClient (const std::string &clientName, const std::string &clientDescription)
 
void deregisterClient (const std::string &clientName)
 
std::string serializeLetter (const fipa::acl::Letter &letter, const std::string &signature) const
 

Detailed Description

Service responsible for handling FIPA message and managing the forwarding and relaying.

Usage example of the MessageTransport class

#include <iostream>

class CustomMessageTransport
{
public:
    bool deliverForwardLetter(const std::string& receiverName, const fipa::acl::Letter& letter)
    {
        fipa::acl::ACLMessage msg = letter.getACLMessage();
        std::cout << msg.getContent() << std::endl;

        // List of agents which could not be delivery to
        return fipa::acl::AgentIDList();
    }
};

#include <fipa_services/FipaServices.hpp>
#include <boost/bind.hpp>

using fipa::acl::message_transport;

MessageTransport mts("my-mts");
mts.registerMessageTransport("custom-transport", boost::bind(&CustomTransport::deliverForwardLetter, this, _1,_2));

...
// Some letter from somewhere, here just manually constructed
using fipa::acl;
ACLMessage msg;
msg.setSender( AgentID("my-agent") );
Letter letter( msg, representation::BITEFFICIENT );
...
mts.handle(letter);
...

Constructor & Destructor Documentation

◆ MessageTransport()

fipa::services::message_transport::MessageTransport::MessageTransport ( const fipa::acl::AgentID &  id,
ServiceDirectory::Ptr  serviceDirectory 
)

Constructor for MessageTransport.

Parameters
idAgent id for this message transport for registered agents)

Member Function Documentation

◆ activateTransport()

void fipa::services::message_transport::MessageTransport::activateTransport ( transports::Transport::Type  type)

Activate a transport given by type This start the transport

Exceptions
std::runtime_errorwhen a transport has already been activated

◆ activateTransports() [1/2]

void fipa::services::message_transport::MessageTransport::activateTransports ( const std::vector< std::string > &  transports)

Activate the given transports

Parameters
listof transports that shall be activated – names need to corresponding to inbuilt transports
See also
fipa::services::transports::Transport
Exceptions
std::runtime_errorwhen a transport has already been activated

◆ activateTransports() [2/2]

void fipa::services::message_transport::MessageTransport::activateTransports ( transports::Transport::Type  flags)

Activate transports as indicated by flags,e.g.

    MessageTransport mt = MessageTransport( AgentID("agent"), ServiceDirectory::Ptr( new ServiceDirectory()));
    mt.activateTransports( transports::Transport::UDT | transports::Transport::TCP );
Exceptions
std::runtime_errorwhen a transport has already been activated

◆ addAcceptedServiceSignature()

void fipa::services::message_transport::MessageTransport::addAcceptedServiceSignature ( const std::string &  signature)
inline

Service signature are part of the locator which is stored in the ServiceDirectory. The MessageTransport handles only services with service signature that are 'accepted'. This adds the given signature to the whitelist of accepted signatures.

Parameters
signatureService signature

◆ configure()

void fipa::services::message_transport::MessageTransport::configure ( const std::vector< transports::Configuration > &  configurations)
inline

◆ deregisterClient()

void fipa::services::message_transport::MessageTransport::deregisterClient ( const std::string &  clientName)

Allows to register a client which is added to the service directory accordingly

Parameters
clientNameName of client to deregister
Exceptions
fipa::services::NotFoundwhen client could not be found

◆ deregisterMessageTransport()

void fipa::services::message_transport::MessageTransport::deregisterMessageTransport ( const std::string &  id)

Deregister a MessageTransportHandler

Exceptions
Duplicate

◆ getAgentID()

fipa::acl::AgentID fipa::services::message_transport::MessageTransport::getAgentID ( ) const
inline

◆ getInternalMessageRepresentationType()

fipa::acl::representation::Type fipa::services::message_transport::MessageTransport::getInternalMessageRepresentationType ( ) const
inline

Get type of the internal message representation

Returns
the message representation to be used

◆ getServiceDirectory()

ServiceDirectory::Ptr fipa::services::message_transport::MessageTransport::getServiceDirectory ( )
inline

Get the service directory that is associated with this MessageTransport

Returns
service directory

◆ getServiceSignature()

std::string fipa::services::message_transport::MessageTransport::getServiceSignature ( ) const
inline

Get the service signature of the MessageTransport

◆ getTransportEndpoints()

std::vector< fipa::services::ServiceLocation > fipa::services::message_transport::MessageTransport::getTransportEndpoints ( ) const

Get the endpoints of the inbuilt transports

Returns
ServiceLocations of active transports

◆ handle()

void fipa::services::message_transport::MessageTransport::handle ( fipa::acl::Letter &  msg)

Handle message, i.e. check forward – create and internal ticket (based on the conversation id and interprete error messages correctly)

◆ handleError()

void fipa::services::message_transport::MessageTransport::handleError ( const fipa::acl::Letter &  msg) const

Handle error, i.e. generate an error message from the original message

◆ handleInternalCommunication()

bool fipa::services::message_transport::MessageTransport::handleInternalCommunication ( const fipa::acl::Letter &  letter)

Handle an internal communication, i.e. for exchange of information between two message transport services

Returns
true if the processed letter was for internal process only, false if this message needs to be processed further

◆ modifyMessageTransport()

void fipa::services::message_transport::MessageTransport::modifyMessageTransport ( const std::string &  id,
MessageTransportHandler  handler 
)

Modify existing MessageTransportHandler

Exceptions
Duplicate

◆ registerClient()

void fipa::services::message_transport::MessageTransport::registerClient ( const std::string &  clientName,
const std::string &  clientDescription 
)

Allows to register a client which is added to the service directory accordingly Locators of this client will be set according to the activated transports

Parameters
clientNameName of client to register
clientDescriptionDescription of client to register

◆ registerMessageTransport()

void fipa::services::message_transport::MessageTransport::registerMessageTransport ( const std::string &  id,
MessageTransportHandler  handler 
)

Register a TransportHandler (the order of registration determines the priority) for local (!) delivery

Exceptions
Duplicate

◆ serializeLetter()

std::string fipa::services::message_transport::MessageTransport::serializeLetter ( const fipa::acl::Letter &  letter,
const std::string &  signature 
) const

Serialize letter according to requirement of the signature

Returns
serialized data

◆ setInternalMessageRepresentationType()

void fipa::services::message_transport::MessageTransport::setInternalMessageRepresentationType ( const fipa::acl::representation::Type &  representation)
inline

Set the internal message representation type

Parameters
messagerepresentation

◆ trigger()

void fipa::services::message_transport::MessageTransport::trigger ( )

Trigger the MessageTransport and all associated underlying transports to process messages and establishing connections


The documentation for this class was generated from the following files: