mirror of
https://github.com/JulianGro/overte.git
synced 2025-07-14 09:06:34 +02:00
correct timing for assignment-client check in
This commit is contained in:
parent
9eef894e24
commit
f18a40dc89
2 changed files with 36 additions and 30 deletions
|
@ -16,7 +16,7 @@
|
|||
#include <PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
const int ASSIGNMENT_REQUEST_INTERVAL_USECS = 1 * 1000 * 1000;
|
||||
const long long ASSIGNMENT_REQUEST_INTERVAL_USECS = 1 * 1000 * 1000;
|
||||
|
||||
int main(int argc, char* const argv[]) {
|
||||
|
||||
|
@ -28,6 +28,8 @@ int main(int argc, char* const argv[]) {
|
|||
// change the timeout on the nodelist socket to be as often as we want to re-request
|
||||
nodeList->getNodeSocket()->setBlockingReceiveTimeoutInUsecs(ASSIGNMENT_REQUEST_INTERVAL_USECS);
|
||||
|
||||
timeval lastRequest = {};
|
||||
|
||||
unsigned char packetData[MAX_PACKET_SIZE];
|
||||
ssize_t receivedBytes = 0;
|
||||
|
||||
|
@ -51,12 +53,15 @@ int main(int argc, char* const argv[]) {
|
|||
Assignment requestAssignment(Assignment::Request, Assignment::All, assignmentPool);
|
||||
|
||||
while (true) {
|
||||
if (usecTimestampNow() - usecTimestamp(&lastRequest) >= ASSIGNMENT_REQUEST_INTERVAL_USECS) {
|
||||
gettimeofday(&lastRequest, NULL);
|
||||
// if we're here we have no assignment, so send a request
|
||||
qDebug() << "Sending an assignment request -" << requestAssignment;
|
||||
nodeList->sendAssignment(requestAssignment);
|
||||
}
|
||||
|
||||
while (nodeList->getNodeSocket()->receive(packetData, &receivedBytes)) {
|
||||
if (packetData[0] == PACKET_TYPE_DEPLOY_ASSIGNMENT && packetVersionMatch(packetData)) {
|
||||
if (nodeList->getNodeSocket()->receive(packetData, &receivedBytes) &&
|
||||
packetData[0] == PACKET_TYPE_DEPLOY_ASSIGNMENT && packetVersionMatch(packetData)) {
|
||||
|
||||
// construct the deployed assignment from the packet data
|
||||
Assignment deployedAssignment(packetData, receivedBytes);
|
||||
|
@ -74,6 +79,7 @@ int main(int argc, char* const argv[]) {
|
|||
if (deployedAssignment.getType() == Assignment::AudioMixer) {
|
||||
AudioMixer::run();
|
||||
} else {
|
||||
qDebug() << "Running as an avatar mixer!";
|
||||
AvatarMixer::run();
|
||||
}
|
||||
|
||||
|
@ -84,5 +90,4 @@ int main(int argc, char* const argv[]) {
|
|||
nodeList->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -255,6 +255,7 @@ void NodeList::clear() {
|
|||
}
|
||||
|
||||
_numNodes = 0;
|
||||
_numNoReplyDomainCheckIns = 0;
|
||||
}
|
||||
|
||||
void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest) {
|
||||
|
|
Loading…
Reference in a new issue