mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 16:36:54 +02:00
Merge pull request #963 from birarda/assignment
domain-server check in and assignment cleanup
This commit is contained in:
commit
9c320e9827
5 changed files with 33 additions and 12 deletions
|
@ -101,7 +101,7 @@ void childClient() {
|
||||||
|
|
||||||
// reset our NodeList by switching back to unassigned and clearing the list
|
// reset our NodeList by switching back to unassigned and clearing the list
|
||||||
nodeList->setOwnerType(NODE_TYPE_UNASSIGNED);
|
nodeList->setOwnerType(NODE_TYPE_UNASSIGNED);
|
||||||
nodeList->clear();
|
nodeList->reset();
|
||||||
|
|
||||||
// reset the logging target to the the CHILD_TARGET_NAME
|
// reset the logging target to the the CHILD_TARGET_NAME
|
||||||
Logging::setTargetName(CHILD_TARGET_NAME);
|
Logging::setTargetName(CHILD_TARGET_NAME);
|
||||||
|
|
|
@ -193,12 +193,20 @@ int main(int argc, const char* argv[]) {
|
||||||
if (!nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER) &&
|
if (!nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER) &&
|
||||||
std::find(::assignmentQueue.begin(), assignmentQueue.end(), &avatarMixerAssignment) == ::assignmentQueue.end()) {
|
std::find(::assignmentQueue.begin(), assignmentQueue.end(), &avatarMixerAssignment) == ::assignmentQueue.end()) {
|
||||||
qDebug("Missing an avatar mixer and assignment not in queue. Adding.\n");
|
qDebug("Missing an avatar mixer and assignment not in queue. Adding.\n");
|
||||||
|
|
||||||
|
// reset the UUID so it is new
|
||||||
|
avatarMixerAssignment.resetUUID();
|
||||||
|
|
||||||
::assignmentQueue.push_front(&avatarMixerAssignment);
|
::assignmentQueue.push_front(&avatarMixerAssignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER) &&
|
if (!nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER) &&
|
||||||
std::find(::assignmentQueue.begin(), ::assignmentQueue.end(), &audioMixerAssignment) == ::assignmentQueue.end()) {
|
std::find(::assignmentQueue.begin(), ::assignmentQueue.end(), &audioMixerAssignment) == ::assignmentQueue.end()) {
|
||||||
qDebug("Missing an audio mixer and assignment not in queue. Adding.\n");
|
qDebug("Missing an audio mixer and assignment not in queue. Adding.\n");
|
||||||
|
|
||||||
|
// reset the UUID so it is new
|
||||||
|
audioMixerAssignment.resetUUID();
|
||||||
|
|
||||||
::assignmentQueue.push_front(&audioMixerAssignment);
|
::assignmentQueue.push_front(&audioMixerAssignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +273,6 @@ int main(int argc, const char* argv[]) {
|
||||||
Assignment::Type matchType = nodeType == NODE_TYPE_AUDIO_MIXER
|
Assignment::Type matchType = nodeType == NODE_TYPE_AUDIO_MIXER
|
||||||
? Assignment::AudioMixerType : Assignment::AvatarMixerType;
|
? Assignment::AudioMixerType : Assignment::AvatarMixerType;
|
||||||
|
|
||||||
|
|
||||||
// enumerate the assignments and see if there is a type and UUID match
|
// enumerate the assignments and see if there is a type and UUID match
|
||||||
while (assignment != ::assignmentQueue.end()) {
|
while (assignment != ::assignmentQueue.end()) {
|
||||||
|
|
||||||
|
@ -386,6 +393,7 @@ int main(int argc, const char* argv[]) {
|
||||||
// keep audio-mixer and avatar-mixer assignments in the queue
|
// keep audio-mixer and avatar-mixer assignments in the queue
|
||||||
// until we get a check-in from that GUID
|
// until we get a check-in from that GUID
|
||||||
// but stick it at the back so the others have a chance to go out
|
// but stick it at the back so the others have a chance to go out
|
||||||
|
|
||||||
::assignmentQueue.push_back(sentAssignment);
|
::assignmentQueue.push_back(sentAssignment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@ public:
|
||||||
|
|
||||||
const QUuid& getUUID() const { return _uuid; }
|
const QUuid& getUUID() const { return _uuid; }
|
||||||
QString getUUIDStringWithoutCurlyBraces() const;
|
QString getUUIDStringWithoutCurlyBraces() const;
|
||||||
|
void resetUUID() { _uuid = QUuid::createUuid(); }
|
||||||
|
|
||||||
Assignment::Command getCommand() const { return _command; }
|
Assignment::Command getCommand() const { return _command; }
|
||||||
Assignment::Type getType() const { return _type; }
|
Assignment::Type getType() const { return _type; }
|
||||||
Assignment::Location getLocation() const { return _location; }
|
Assignment::Location getLocation() const { return _location; }
|
||||||
|
|
|
@ -70,7 +70,9 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
|
||||||
_ownerID(UNKNOWN_NODE_ID),
|
_ownerID(UNKNOWN_NODE_ID),
|
||||||
_lastNodeID(UNKNOWN_NODE_ID + 1),
|
_lastNodeID(UNKNOWN_NODE_ID + 1),
|
||||||
_numNoReplyDomainCheckIns(0),
|
_numNoReplyDomainCheckIns(0),
|
||||||
_assignmentServerSocket(NULL)
|
_assignmentServerSocket(NULL),
|
||||||
|
_checkInPacket(NULL),
|
||||||
|
_numBytesCheckInPacket(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -263,7 +265,16 @@ void NodeList::clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_numNodes = 0;
|
_numNodes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeList::reset() {
|
||||||
|
clear();
|
||||||
_numNoReplyDomainCheckIns = 0;
|
_numNoReplyDomainCheckIns = 0;
|
||||||
|
|
||||||
|
delete[] _checkInPacket;
|
||||||
|
_checkInPacket = NULL;
|
||||||
|
|
||||||
|
_numBytesCheckInPacket = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest) {
|
void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest) {
|
||||||
|
@ -304,11 +315,8 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
|
||||||
printedDomainServerIP = true;
|
printedDomainServerIP = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* checkInPacket = NULL;
|
|
||||||
int checkInPacketSize = 0;
|
|
||||||
|
|
||||||
// construct the DS check in packet if we need to
|
// construct the DS check in packet if we need to
|
||||||
if (!checkInPacket) {
|
if (!_checkInPacket) {
|
||||||
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
|
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
|
||||||
|
|
||||||
const int IP_ADDRESS_BYTES = 4;
|
const int IP_ADDRESS_BYTES = 4;
|
||||||
|
@ -317,8 +325,8 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
|
||||||
int numPacketBytes = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION) + sizeof(NODE_TYPE) +
|
int numPacketBytes = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION) + sizeof(NODE_TYPE) +
|
||||||
NUM_BYTES_RFC4122_UUID + sizeof(uint16_t) + IP_ADDRESS_BYTES + numBytesNodesOfInterest + sizeof(unsigned char);
|
NUM_BYTES_RFC4122_UUID + sizeof(uint16_t) + IP_ADDRESS_BYTES + numBytesNodesOfInterest + sizeof(unsigned char);
|
||||||
|
|
||||||
checkInPacket = new unsigned char[numPacketBytes];
|
_checkInPacket = new unsigned char[numPacketBytes];
|
||||||
unsigned char* packetPosition = checkInPacket;
|
unsigned char* packetPosition = _checkInPacket;
|
||||||
|
|
||||||
PACKET_TYPE nodePacketType = (memchr(SOLO_NODE_TYPES, _ownerType, sizeof(SOLO_NODE_TYPES)))
|
PACKET_TYPE nodePacketType = (memchr(SOLO_NODE_TYPES, _ownerType, sizeof(SOLO_NODE_TYPES)))
|
||||||
? PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY
|
? PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY
|
||||||
|
@ -335,7 +343,7 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
|
||||||
packetPosition += NUM_BYTES_RFC4122_UUID;
|
packetPosition += NUM_BYTES_RFC4122_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
packetPosition += packSocket(checkInPacket + (packetPosition - checkInPacket),
|
packetPosition += packSocket(_checkInPacket + (packetPosition - _checkInPacket),
|
||||||
getLocalAddress(),
|
getLocalAddress(),
|
||||||
htons(_nodeSocket.getListeningPort()));
|
htons(_nodeSocket.getListeningPort()));
|
||||||
|
|
||||||
|
@ -350,10 +358,10 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
|
||||||
packetPosition += numBytesNodesOfInterest;
|
packetPosition += numBytesNodesOfInterest;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkInPacketSize = packetPosition - checkInPacket;
|
_numBytesCheckInPacket = packetPosition - _checkInPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
_nodeSocket.send(_domainIP.toString().toStdString().c_str(), _domainPort, checkInPacket, checkInPacketSize);
|
_nodeSocket.send(_domainIP.toString().toStdString().c_str(), _domainPort, _checkInPacket, _numBytesCheckInPacket);
|
||||||
|
|
||||||
// increment the count of un-replied check-ins
|
// increment the count of un-replied check-ins
|
||||||
_numNoReplyDomainCheckIns++;
|
_numNoReplyDomainCheckIns++;
|
||||||
|
|
|
@ -98,6 +98,7 @@ public:
|
||||||
int getNumNoReplyDomainCheckIns() const { return _numNoReplyDomainCheckIns; }
|
int getNumNoReplyDomainCheckIns() const { return _numNoReplyDomainCheckIns; }
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
void reset();
|
||||||
|
|
||||||
void setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest);
|
void setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest);
|
||||||
|
|
||||||
|
@ -159,6 +160,8 @@ private:
|
||||||
pthread_t checkInWithDomainServerThread;
|
pthread_t checkInWithDomainServerThread;
|
||||||
int _numNoReplyDomainCheckIns;
|
int _numNoReplyDomainCheckIns;
|
||||||
sockaddr* _assignmentServerSocket;
|
sockaddr* _assignmentServerSocket;
|
||||||
|
uchar* _checkInPacket;
|
||||||
|
int _numBytesCheckInPacket;
|
||||||
|
|
||||||
void handlePingReply(sockaddr *nodeAddress);
|
void handlePingReply(sockaddr *nodeAddress);
|
||||||
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
||||||
|
|
Loading…
Reference in a new issue