mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 22:44:15 +02:00
added NodeListHook to JurisdictionListener to properly remove nodes that are killed
This commit is contained in:
parent
526270e408
commit
50532bc67d
2 changed files with 24 additions and 1 deletions
|
@ -19,6 +19,21 @@
|
|||
JurisdictionListener::JurisdictionListener(PacketSenderNotify* notify) :
|
||||
PacketSender(notify, JurisdictionListener::DEFAULT_PACKETS_PER_SECOND)
|
||||
{
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
nodeList->addHook(this);
|
||||
}
|
||||
|
||||
JurisdictionListener::~JurisdictionListener() {
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
nodeList->removeHook(this);
|
||||
}
|
||||
|
||||
void JurisdictionListener::nodeAdded(Node* node) {
|
||||
// nothing to do. But need to implement it.
|
||||
}
|
||||
|
||||
void JurisdictionListener::nodeKilled(Node* node) {
|
||||
_jurisdictions.erase(_jurisdictions.find(node->getNodeID()));
|
||||
}
|
||||
|
||||
bool JurisdictionListener::queueJurisdictionRequest() {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#ifndef __shared__JurisdictionListener__
|
||||
#define __shared__JurisdictionListener__
|
||||
|
||||
#include <NodeList.h>
|
||||
#include <PacketSender.h>
|
||||
#include <ReceivedPacketProcessor.h>
|
||||
|
||||
|
@ -20,15 +21,22 @@
|
|||
/// the PACKET_TYPE_VOXEL_JURISDICTION packets it receives in order to maintain an accurate state of all jurisidictions
|
||||
/// within the domain. As with other ReceivedPacketProcessor classes the user is responsible for reading inbound packets
|
||||
/// and adding them to the processing queue by calling queueReceivedPacket()
|
||||
class JurisdictionListener : public PacketSender, public ReceivedPacketProcessor {
|
||||
class JurisdictionListener : public NodeListHook, public PacketSender, public ReceivedPacketProcessor {
|
||||
public:
|
||||
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
||||
|
||||
JurisdictionListener(PacketSenderNotify* notify = NULL);
|
||||
~JurisdictionListener();
|
||||
|
||||
virtual bool process();
|
||||
|
||||
NodeToJurisdictionMap* getJurisdictions() { return &_jurisdictions; };
|
||||
|
||||
/// Called by NodeList to inform us that a node has been added.
|
||||
void nodeAdded(Node* node);
|
||||
/// Called by NodeList to inform us that a node has been killed.
|
||||
void nodeKilled(Node* node);
|
||||
|
||||
protected:
|
||||
/// Callback for processing of received packets. Will process any queued PACKET_TYPE_VOXEL_JURISDICTION and update the
|
||||
/// jurisdiction map member variable
|
||||
|
|
Loading…
Reference in a new issue