108 lines
3.2 KiB
C++
108 lines
3.2 KiB
C++
|
|
#include "LTMessage.h"
|
|
|
|
#include "Dispatcher.h"
|
|
#include "common/validator/MessageValidator.h"
|
|
#include "fd/NetworkFailureDetector.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
/**
|
|
* @brief Constructor.
|
|
* @param mref MessageReference
|
|
* @param sourceID PeerID
|
|
* @param sequ Sequence number
|
|
* @param lt Local time
|
|
*
|
|
* This will initialize the last hop with the local one.
|
|
*/
|
|
LTMessage::LTMessage( const MessageReference& mref, const PeerID& sourceID, const int& sequ, const VirtualLogicalTime& lt)
|
|
: MoversightMessage( "LT", LT) {
|
|
setMessageReference( mref);
|
|
setSourceID( sourceID);
|
|
setLastHop( sourceID);
|
|
setSequ( sequ);
|
|
setLT( lt);
|
|
}
|
|
|
|
/**
|
|
* @brief Constructor.
|
|
* @param mref MessageReference
|
|
* @param sourceID PeerID
|
|
* @param lastHopID PeerId of the last hop
|
|
* @param sequ sequence number
|
|
* @param lt local time
|
|
*
|
|
* This will initialize the last hop with the given one.
|
|
*/
|
|
LTMessage::LTMessage( const MessageReference& mref, const PeerID& sourceID, const PeerID& lastHopID, const int& sequ, const VirtualLogicalTime& lt)
|
|
: MoversightMessage( "LT", LT) {
|
|
setMessageReference( mref);
|
|
setSourceID( sourceID);
|
|
setLastHop( lastHopID);
|
|
setSequ( sequ);
|
|
setLT( lt);
|
|
}
|
|
|
|
/**
|
|
* @brief Default Constructor.
|
|
*/
|
|
LTMessage::LTMessage()
|
|
: MoversightMessage("LT", LT) {
|
|
}
|
|
|
|
/**
|
|
* @brief Destructor.
|
|
*/
|
|
LTMessage::~LTMessage() {
|
|
}
|
|
|
|
/**
|
|
* @brief Copy Constructor.
|
|
* @param orig The instance to copy
|
|
*/
|
|
LTMessage::LTMessage( const LTMessage& other)
|
|
: MoversightMessage( other) {
|
|
operator=( other);
|
|
}
|
|
|
|
/**
|
|
* @brief Duplicates the Message.
|
|
* @return Duplicated message.
|
|
*/
|
|
LTMessage* LTMessage::dup() const {
|
|
return new LTMessage(*this);
|
|
}
|
|
|
|
/**
|
|
* @brief Assignment operator.
|
|
* @param other The instance to assign.
|
|
* @return a reference to the this instance
|
|
*/
|
|
LTMessage& LTMessage::operator=( const LTMessage& other) {
|
|
MoversightMessage::operator=( other);
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Handle this message.
|
|
* @param dis A reference to the dispatcher, used to forward this message to the handling modules.
|
|
*
|
|
* Before the message can be handled, it has to be successfully validated.
|
|
*
|
|
* @note Will be replaced by using the event system to forward this message.
|
|
*/
|
|
void
|
|
LTMessage::handleReceive( Dispatcher& dis) {
|
|
// validate the message
|
|
if( dis.getMessageValidator()->isValid( *this)) {
|
|
// notify the NFD about ongoing traffic
|
|
dis.getNetworkFailureDetector().handleMessage( this);
|
|
// handle the message
|
|
dis.getMessageTransfer().handleMessage(this);
|
|
}//End if
|
|
}
|
|
}
|
|
}
|