111 lines
3.6 KiB
C++
111 lines
3.6 KiB
C++
|
|
#include "TempGroupAnnounce.h"
|
|
|
|
#include "Dispatcher.h"
|
|
#include "common/validator/MessageValidator.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
/**
|
|
* @brief Default Constructor
|
|
*/
|
|
TempGroupAnnounce::TempGroupAnnounce() : ExteriorMessage("TGA", TGA) { }
|
|
|
|
/**
|
|
* @brief Destructor
|
|
*/
|
|
TempGroupAnnounce::~TempGroupAnnounce() { }
|
|
|
|
/**
|
|
* @brief Copy constructor
|
|
* @param other The instance to copy
|
|
*/
|
|
TempGroupAnnounce::TempGroupAnnounce(const TempGroupAnnounce& other)
|
|
: ExteriorMessage(other) {
|
|
operator =(other);
|
|
}
|
|
|
|
/**
|
|
* @brief Duplicate method. Creates a copy of the current message.
|
|
* @return The copy of the current instance.
|
|
*/
|
|
TempGroupAnnounce *
|
|
TempGroupAnnounce::dup() const {
|
|
return new TempGroupAnnounce(*this);
|
|
}
|
|
|
|
/**
|
|
* @brief Assignment operator
|
|
* @param other The instance to assign.
|
|
* @return A reference to the local instance.
|
|
*/
|
|
TempGroupAnnounce &
|
|
TempGroupAnnounce::operator=(const TempGroupAnnounce& other) {
|
|
if( this == &other) return *this;
|
|
ExteriorMessage::operator=(other);
|
|
this->peersInCluster = other.peersInCluster;
|
|
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
|
|
TempGroupAnnounce::handleReceive(Dispatcher & dis) {
|
|
// @NOTE this has been a multicast message?
|
|
|
|
//validate the message
|
|
// if (dis.getMessageValidator()->isValid(this)) {
|
|
//handle the message
|
|
dis.getMobilitySupport().handleTempGroupAnnounce(*this);
|
|
// 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
|
|
TempGroupAnnounce::handleDeliver(Dispatcher & dis, const PeerIDList & missedPeers) {
|
|
// @NOTE this is not delivered?
|
|
|
|
//deliver the message
|
|
if (dis.getLocalStateOperation() != LOCKED) {
|
|
// dis.getMobilitySupport().handleTempGroupAnnounce(*this, missedPeers);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief Gets the peers who became disjoined.
|
|
* @return PeerIDList of non-reachable peers
|
|
*/
|
|
const PeerIDList&
|
|
TempGroupAnnounce::getPeersInCluster() const {
|
|
return peersInCluster;
|
|
}
|
|
|
|
/**
|
|
* @brief Sets the list of peers who became disjoined.
|
|
* @param pIDList - Those peers who left the group.
|
|
*/
|
|
void
|
|
TempGroupAnnounce::setPeersInCluster( const PeerIDList& pIDList) {
|
|
this->peersInCluster = pIDList;
|
|
}
|
|
|
|
/**
|
|
* @brief Archive method
|
|
* @param archive The archive to which the attributes are to add
|
|
*/
|
|
void
|
|
TempGroupAnnounce::set(Archive & archive) {
|
|
ExteriorMessage::set(archive);
|
|
archive(peersInCluster);
|
|
}
|
|
}
|
|
}
|