Files
scandocs/uni/masterarbeit/source/moversight/ms/msg/PeerReconnectAnnounce.cc
2014-06-30 13:58:10 +02:00

111 lines
3.7 KiB
C++

#include "PeerReconnectAnnounce.h"
#include "Dispatcher.h"
#include "common/validator/MessageValidator.h"
#include "fd/NetworkFailureDetector.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
*/
PeerReconnectAnnounce::PeerReconnectAnnounce() : MulticastMessage("PRA", PRA){
}
/**
* @brief Destructor
*/
PeerReconnectAnnounce::~PeerReconnectAnnounce() {
}
/**
* @brief Copy constructor
* @param other The instance to copy
*/
PeerReconnectAnnounce::PeerReconnectAnnounce(const PeerReconnectAnnounce& other) : MulticastMessage(other) {
operator =(other);
}
/**
* @brief Duplicate method. Creates a copy of the current message.
* @return The copy of the current instance.
*/
PeerReconnectAnnounce *
PeerReconnectAnnounce::dup() const {
return new PeerReconnectAnnounce(*this);
}
/**
* @brief Assignment operator
* @param other The instance to assign.
* @return A reference to the local instance.
*/
PeerReconnectAnnounce &
PeerReconnectAnnounce::operator=(const PeerReconnectAnnounce& other) {
if (this == &other) return *this;
MulticastMessage::operator=(other);
reconnectedPeerID = other.reconnectedPeerID;
return *this;
}
/**
* @brief Handles this message. To handle a message, it has first successfully validated.
* @param dis A reference to the dispatcher, used to forward this message to the handling modules.
*/
void
PeerReconnectAnnounce::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);
}
}
/**
* @brief Handles the message delivering. To deliver a message, the message to each module which is interested in this message.
* @param dis A reference to the dispatcher, used to forward this message to the handling modules.
* @param missedPeers A list of peers, which have missed this message, as they are pending.
*/
void
PeerReconnectAnnounce::handleDeliver(Dispatcher & dis, const PeerIDList & /* missedPeers */) {
//store the message for re-synchronization
dis.getMobilitySupport().storeMessage(*this);
//process the message
dis.getMembershipService().handlePeerReconnectAnnounce(*this);
}
/**
* @brief Gets the Id of the reconnected peer
* @return PeerID of the reconnected Peer
*/
const PeerID&
PeerReconnectAnnounce::getReconnectedPeerID() const {
return reconnectedPeerID;
}
/**
* @brief Sets the PeerID of the reconnected peer
* @param reconnectedPeerID The PeerID of the reconnected Peer to set
*/
void
PeerReconnectAnnounce::setReconnectedPeerID(const PeerID& reconnectedPeerID) {
this->reconnectedPeerID = reconnectedPeerID;
}
/**
* @brief Archive method
* @param archive The archive to which the attributes are to add
*/
void
PeerReconnectAnnounce::set(Archive & archive) {
MulticastMessage::set(archive);
archive(reconnectedPeerID);
}
}
}