mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +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
|
||||
nodeList->setOwnerType(NODE_TYPE_UNASSIGNED);
|
||||
nodeList->clear();
|
||||
nodeList->reset();
|
||||
|
||||
// reset the logging target to the the 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) &&
|
||||
std::find(::assignmentQueue.begin(), assignmentQueue.end(), &avatarMixerAssignment) == ::assignmentQueue.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
if (!nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER) &&
|
||||
std::find(::assignmentQueue.begin(), ::assignmentQueue.end(), &audioMixerAssignment) == ::assignmentQueue.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -265,7 +273,6 @@ int main(int argc, const char* argv[]) {
|
|||
Assignment::Type matchType = nodeType == NODE_TYPE_AUDIO_MIXER
|
||||
? Assignment::AudioMixerType : Assignment::AvatarMixerType;
|
||||
|
||||
|
||||
// enumerate the assignments and see if there is a type and UUID match
|
||||
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
|
||||
// until we get a check-in from that GUID
|
||||
// but stick it at the back so the others have a chance to go out
|
||||
|
||||
::assignmentQueue.push_back(sentAssignment);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ public:
|
|||
|
||||
const QUuid& getUUID() const { return _uuid; }
|
||||
QString getUUIDStringWithoutCurlyBraces() const;
|
||||
void resetUUID() { _uuid = QUuid::createUuid(); }
|
||||
|
||||
Assignment::Command getCommand() const { return _command; }
|
||||
Assignment::Type getType() const { return _type; }
|
||||
Assignment::Location getLocation() const { return _location; }
|
||||
|
|
|
@ -70,7 +70,9 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
|
|||
_ownerID(UNKNOWN_NODE_ID),
|
||||
_lastNodeID(UNKNOWN_NODE_ID + 1),
|
||||
_numNoReplyDomainCheckIns(0),
|
||||
_assignmentServerSocket(NULL)
|
||||
_assignmentServerSocket(NULL),
|
||||
_checkInPacket(NULL),
|
||||
_numBytesCheckInPacket(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -263,7 +265,16 @@ void NodeList::clear() {
|
|||
}
|
||||
|
||||
_numNodes = 0;
|
||||
}
|
||||
|
||||
void NodeList::reset() {
|
||||
clear();
|
||||
_numNoReplyDomainCheckIns = 0;
|
||||
|
||||
delete[] _checkInPacket;
|
||||
_checkInPacket = NULL;
|
||||
|
||||
_numBytesCheckInPacket = 0;
|
||||
}
|
||||
|
||||
void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest) {
|
||||
|
@ -304,11 +315,8 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
|
|||
printedDomainServerIP = true;
|
||||
}
|
||||
|
||||
unsigned char* checkInPacket = NULL;
|
||||
int checkInPacketSize = 0;
|
||||
|
||||
// construct the DS check in packet if we need to
|
||||
if (!checkInPacket) {
|
||||
if (!_checkInPacket) {
|
||||
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
|
||||
|
||||
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) +
|
||||
NUM_BYTES_RFC4122_UUID + sizeof(uint16_t) + IP_ADDRESS_BYTES + numBytesNodesOfInterest + sizeof(unsigned char);
|
||||
|
||||
checkInPacket = new unsigned char[numPacketBytes];
|
||||
unsigned char* packetPosition = checkInPacket;
|
||||
_checkInPacket = new unsigned char[numPacketBytes];
|
||||
unsigned char* packetPosition = _checkInPacket;
|
||||
|
||||
PACKET_TYPE nodePacketType = (memchr(SOLO_NODE_TYPES, _ownerType, sizeof(SOLO_NODE_TYPES)))
|
||||
? PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY
|
||||
|
@ -335,7 +343,7 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
|
|||
packetPosition += NUM_BYTES_RFC4122_UUID;
|
||||
}
|
||||
|
||||
packetPosition += packSocket(checkInPacket + (packetPosition - checkInPacket),
|
||||
packetPosition += packSocket(_checkInPacket + (packetPosition - _checkInPacket),
|
||||
getLocalAddress(),
|
||||
htons(_nodeSocket.getListeningPort()));
|
||||
|
||||
|
@ -350,10 +358,10 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
|
|||
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
|
||||
_numNoReplyDomainCheckIns++;
|
||||
|
|
|
@ -98,6 +98,7 @@ public:
|
|||
int getNumNoReplyDomainCheckIns() const { return _numNoReplyDomainCheckIns; }
|
||||
|
||||
void clear();
|
||||
void reset();
|
||||
|
||||
void setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest);
|
||||
|
||||
|
@ -159,6 +160,8 @@ private:
|
|||
pthread_t checkInWithDomainServerThread;
|
||||
int _numNoReplyDomainCheckIns;
|
||||
sockaddr* _assignmentServerSocket;
|
||||
uchar* _checkInPacket;
|
||||
int _numBytesCheckInPacket;
|
||||
|
||||
void handlePingReply(sockaddr *nodeAddress);
|
||||
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
||||
|
|
Loading…
Reference in a new issue