mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:56:44 +02:00
have stubbed Operative check in with DS
This commit is contained in:
parent
6a253f78d1
commit
b5a47cddc0
2 changed files with 27 additions and 2 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
|
#include "NodeTypes.h"
|
||||||
#include "UDPSocket.h"
|
#include "UDPSocket.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -48,7 +49,8 @@ public:
|
||||||
NodeListIterator begin() const;
|
NodeListIterator begin() const;
|
||||||
NodeListIterator end() const;
|
NodeListIterator end() const;
|
||||||
|
|
||||||
char getOwnerType() const { return _ownerType; }
|
NODE_TYPE getOwnerType() const { return _ownerType; }
|
||||||
|
void setOwnerType(NODE_TYPE ownerType) { _ownerType = ownerType; }
|
||||||
|
|
||||||
uint16_t getLastNodeID() const { return _lastNodeID; }
|
uint16_t getLastNodeID() const { return _lastNodeID; }
|
||||||
void increaseNodeID() { ++_lastNodeID; }
|
void increaseNodeID() { ++_lastNodeID; }
|
||||||
|
|
|
@ -200,13 +200,36 @@ const double OUR_FPS_IN_MILLISECONDS = 1000.0/ACTUAL_FPS; // determines FPS from
|
||||||
const int ANIMATE_VOXELS_INTERVAL_USECS = OUR_FPS_IN_MILLISECONDS * 1000.0; // converts from milliseconds to usecs
|
const int ANIMATE_VOXELS_INTERVAL_USECS = OUR_FPS_IN_MILLISECONDS * 1000.0; // converts from milliseconds to usecs
|
||||||
|
|
||||||
void Operative::run() {
|
void Operative::run() {
|
||||||
timeval lastSendTime;
|
timeval lastSendTime = {};
|
||||||
|
timeval lastDomainServerCheckIn = {};
|
||||||
|
|
||||||
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
|
sockaddr nodePublicAddress;
|
||||||
|
|
||||||
|
unsigned char* packetData = new unsigned char[MAX_PACKET_SIZE];
|
||||||
|
ssize_t receivedBytes;
|
||||||
|
|
||||||
|
// change the owner type on our NodeList
|
||||||
|
NodeList::getInstance()->setOwnerType(NODE_TYPE_AGENT);
|
||||||
|
NodeList::getInstance()->setNodeTypesOfInterest(&NODE_TYPE_VOXEL_SERVER, 1);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
gettimeofday(&lastSendTime, NULL);
|
gettimeofday(&lastSendTime, NULL);
|
||||||
|
|
||||||
renderMovingBug();
|
renderMovingBug();
|
||||||
|
|
||||||
|
// send a check in packet to the domain server if DOMAIN_SERVER_CHECK_IN_USECS has elapsed
|
||||||
|
if (usecTimestampNow() - usecTimestamp(&lastDomainServerCheckIn) >= DOMAIN_SERVER_CHECK_IN_USECS) {
|
||||||
|
gettimeofday(&lastDomainServerCheckIn, NULL);
|
||||||
|
NodeList::getInstance()->sendDomainServerCheckIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nodes sending messages to us...
|
||||||
|
if (nodeList->getNodeSocket()->receive(&nodePublicAddress, packetData, &receivedBytes)) {
|
||||||
|
NodeList::getInstance()->processNodeData(&nodePublicAddress, packetData, receivedBytes);
|
||||||
|
}
|
||||||
|
|
||||||
// dynamically sleep until we need to fire off the next set of voxels
|
// dynamically sleep until we need to fire off the next set of voxels
|
||||||
long long usecToSleep = ANIMATE_VOXELS_INTERVAL_USECS - (usecTimestampNow() - usecTimestamp(&lastSendTime));
|
long long usecToSleep = ANIMATE_VOXELS_INTERVAL_USECS - (usecTimestampNow() - usecTimestamp(&lastSendTime));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue