mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 09:25:31 +02:00
change node types of interest to a QSet
This commit is contained in:
parent
7fb062cf84
commit
e9e2557576
10 changed files with 24 additions and 35 deletions
|
@ -807,7 +807,7 @@ AnimationServer::AnimationServer(int &argc, char **argv) :
|
|||
|
||||
pthread_create(&::animateVoxelThread, NULL, animateVoxels, NULL);
|
||||
|
||||
NodeList::getInstance()->setNodeTypesOfInterest(&NODE_TYPE_VOXEL_SERVER, 1);
|
||||
NodeList::getInstance()->addNodeTypeToInterestSet(NODE_TYPE_VOXEL_SERVER);
|
||||
|
||||
QTimer* domainServerTimer = new QTimer(this);
|
||||
connect(domainServerTimer, SIGNAL(timeout()), nodeList, SLOT(sendDomainServerCheckIn()));
|
||||
|
|
|
@ -55,10 +55,8 @@ void Agent::run() {
|
|||
// XXXBHG - this seems less than ideal. There might be classes (like jurisdiction listeners, that need access to
|
||||
// other node types, but for them to get access to those node types, we have to add them here. It seems like
|
||||
// NodeList should support adding types of interest
|
||||
const NODE_TYPE AGENT_NODE_TYPES_OF_INTEREST[] = { NODE_TYPE_VOXEL_SERVER, NODE_TYPE_PARTICLE_SERVER,
|
||||
NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER };
|
||||
|
||||
nodeList->setNodeTypesOfInterest(AGENT_NODE_TYPES_OF_INTEREST, sizeof(AGENT_NODE_TYPES_OF_INTEREST));
|
||||
nodeList->addSetOfNodeTypesToNodeInterestSet(QSet<NODE_TYPE>() << NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
|
||||
<< NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER);
|
||||
|
||||
// figure out the URL for the script for this agent assignment
|
||||
QString scriptURLString("http://%1:8080/assignment/%2");
|
||||
|
|
|
@ -241,8 +241,7 @@ void AudioMixer::run() {
|
|||
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
|
||||
const char AUDIO_MIXER_NODE_TYPES_OF_INTEREST[2] = { NODE_TYPE_AGENT, NODE_TYPE_AUDIO_INJECTOR };
|
||||
nodeList->setNodeTypesOfInterest(AUDIO_MIXER_NODE_TYPES_OF_INTEREST, sizeof(AUDIO_MIXER_NODE_TYPES_OF_INTEREST));
|
||||
nodeList->addNodeTypeToInterestSet(NODE_TYPE_AGENT);
|
||||
|
||||
nodeList->linkedDataCreateCallback = attachNewBufferToNode;
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ void AvatarMixer::run() {
|
|||
commonInit(AVATAR_MIXER_LOGGING_NAME, NODE_TYPE_AVATAR_MIXER);
|
||||
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
nodeList->setNodeTypesOfInterest(&NODE_TYPE_AGENT, 1);
|
||||
nodeList->addNodeTypeToInterestSet(NODE_TYPE_AGENT);
|
||||
|
||||
nodeList->linkedDataCreateCallback = attachAvatarDataToNode;
|
||||
|
||||
|
|
|
@ -221,9 +221,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
#endif
|
||||
|
||||
// tell the NodeList instance who to tell the domain server we care about
|
||||
const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER,
|
||||
NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER};
|
||||
nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
|
||||
nodeList->addSetOfNodeTypesToNodeInterestSet(QSet<NODE_TYPE>() << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER
|
||||
<< NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
|
||||
<< NODE_TYPE_METAVOXEL_SERVER);
|
||||
|
||||
QTimer* silentNodeTimer = new QTimer(this);
|
||||
connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
|
||||
|
|
|
@ -569,8 +569,7 @@ void OctreeServer::run() {
|
|||
nodeList->setOwnerType(getMyNodeType());
|
||||
|
||||
// we need to ask the DS about agents so we can ping/reply with them
|
||||
const char nodeTypesOfInterest[] = { NODE_TYPE_AGENT, NODE_TYPE_ANIMATION_SERVER};
|
||||
nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
|
||||
nodeList->addSetOfNodeTypesToNodeInterestSet(QSet<NODE_TYPE>() << NODE_TYPE_AGENT << NODE_TYPE_ANIMATION_SERVER);
|
||||
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
|
|
|
@ -74,8 +74,6 @@ const char* Node::getTypeName() const {
|
|||
return NODE_TYPE_NAME_AUDIO_MIXER;
|
||||
case NODE_TYPE_AVATAR_MIXER:
|
||||
return NODE_TYPE_NAME_AVATAR_MIXER;
|
||||
case NODE_TYPE_AUDIO_INJECTOR:
|
||||
return NODE_TYPE_NAME_AUDIO_INJECTOR;
|
||||
case NODE_TYPE_ANIMATION_SERVER:
|
||||
return NODE_TYPE_NAME_ANIMATION_SERVER;
|
||||
case NODE_TYPE_UNASSIGNED:
|
||||
|
|
|
@ -61,7 +61,7 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
|
|||
_domainSockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
|
||||
_nodeSocket(),
|
||||
_ownerType(newOwnerType),
|
||||
_nodeTypesOfInterest(NULL),
|
||||
_nodeTypesOfInterest(),
|
||||
_ownerUUID(QUuid::createUuid()),
|
||||
_numNoReplyDomainCheckIns(0),
|
||||
_assignmentServerSocket(),
|
||||
|
@ -75,8 +75,6 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
|
|||
|
||||
|
||||
NodeList::~NodeList() {
|
||||
delete _nodeTypesOfInterest;
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
|
@ -293,19 +291,18 @@ void NodeList::reset() {
|
|||
clear();
|
||||
_numNoReplyDomainCheckIns = 0;
|
||||
|
||||
delete _nodeTypesOfInterest;
|
||||
_nodeTypesOfInterest = NULL;
|
||||
_nodeTypesOfInterest.clear();
|
||||
|
||||
// refresh the owner UUID
|
||||
_ownerUUID = QUuid::createUuid();
|
||||
}
|
||||
|
||||
void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest) {
|
||||
delete _nodeTypesOfInterest;
|
||||
void NodeList::addNodeTypeToInterestSet(NODE_TYPE nodeTypeToAdd) {
|
||||
_nodeTypesOfInterest << nodeTypeToAdd;
|
||||
}
|
||||
|
||||
_nodeTypesOfInterest = new char[numNodeTypesOfInterest + sizeof(char)];
|
||||
memcpy(_nodeTypesOfInterest, nodeTypesOfInterest, numNodeTypesOfInterest);
|
||||
_nodeTypesOfInterest[numNodeTypesOfInterest] = '\0';
|
||||
void NodeList::addSetOfNodeTypesToNodeInterestSet(const QSet<NODE_TYPE>& setOfNodeTypes) {
|
||||
_nodeTypesOfInterest.unite(setOfNodeTypes);
|
||||
}
|
||||
|
||||
const uint32_t RFC_5389_MAGIC_COOKIE = 0x2112A442;
|
||||
|
@ -522,7 +519,7 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
sendSTUNRequest();
|
||||
} else {
|
||||
// construct the DS check in packet if we need to
|
||||
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
|
||||
int numBytesNodesOfInterest = _nodeTypesOfInterest.size();
|
||||
|
||||
const int IP_ADDRESS_BYTES = 4;
|
||||
|
||||
|
@ -563,11 +560,8 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
*(packetPosition++) = numBytesNodesOfInterest;
|
||||
|
||||
// copy over the bytes for node types of interest, if required
|
||||
if (numBytesNodesOfInterest > 0) {
|
||||
memcpy(packetPosition,
|
||||
_nodeTypesOfInterest,
|
||||
numBytesNodesOfInterest);
|
||||
packetPosition += numBytesNodesOfInterest;
|
||||
foreach (NODE_TYPE nodeTypeOfInterest, _nodeTypesOfInterest) {
|
||||
*(packetPosition++) = nodeTypeOfInterest;
|
||||
}
|
||||
|
||||
_nodeSocket.writeDatagram((char*) checkInPacket, packetPosition - checkInPacket,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#endif
|
||||
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtNetwork/QHostAddress>
|
||||
|
@ -89,8 +90,9 @@ public:
|
|||
|
||||
void clear();
|
||||
void reset();
|
||||
|
||||
void setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest);
|
||||
|
||||
void addNodeTypeToInterestSet(NODE_TYPE nodeTypeToAdd);
|
||||
void addSetOfNodeTypesToNodeInterestSet(const QSet<NODE_TYPE>& setOfNodeTypes);
|
||||
|
||||
int processDomainServerList(unsigned char *packetData, size_t dataBytes);
|
||||
|
||||
|
@ -149,7 +151,7 @@ private:
|
|||
HifiSockAddr _domainSockAddr;
|
||||
QUdpSocket _nodeSocket;
|
||||
char _ownerType;
|
||||
char* _nodeTypesOfInterest;
|
||||
QSet<NODE_TYPE> _nodeTypesOfInterest;
|
||||
QUuid _ownerUUID;
|
||||
int _numNoReplyDomainCheckIns;
|
||||
HifiSockAddr _assignmentServerSocket;
|
||||
|
|
|
@ -25,7 +25,6 @@ const NODE_TYPE NODE_TYPE_ENVIRONMENT_SERVER = 'E';
|
|||
const NODE_TYPE NODE_TYPE_AGENT = 'I';
|
||||
const NODE_TYPE NODE_TYPE_AUDIO_MIXER = 'M';
|
||||
const NODE_TYPE NODE_TYPE_AVATAR_MIXER = 'W';
|
||||
const NODE_TYPE NODE_TYPE_AUDIO_INJECTOR = 'A';
|
||||
const NODE_TYPE NODE_TYPE_ANIMATION_SERVER = 'a';
|
||||
const NODE_TYPE NODE_TYPE_UNASSIGNED = 1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue