mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:38:02 +02:00
add method to NodeList to set domain IP to local, move mutex lock to node
This commit is contained in:
parent
12697c6b14
commit
d389dc6e3a
10 changed files with 85 additions and 45 deletions
|
@ -697,8 +697,7 @@ int main(int argc, const char * argv[])
|
||||||
::wantLocalDomain = cmdOptionExists(argc, argv,local);
|
::wantLocalDomain = cmdOptionExists(argc, argv,local);
|
||||||
if (::wantLocalDomain) {
|
if (::wantLocalDomain) {
|
||||||
printf("Local Domain MODE!\n");
|
printf("Local Domain MODE!\n");
|
||||||
int ip = getLocalAddress();
|
nodeList->setDomainIPToLocalhost();
|
||||||
sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeList->linkedDataCreateCallback = NULL; // do we need a callback?
|
nodeList->linkedDataCreateCallback = NULL; // do we need a callback?
|
||||||
|
|
|
@ -70,16 +70,15 @@ bool wantLocalDomain = false;
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||||
|
|
||||||
|
NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AUDIO_MIXER, MIXER_LISTEN_PORT);
|
||||||
|
|
||||||
// Handle Local Domain testing with the --local command line
|
// Handle Local Domain testing with the --local command line
|
||||||
const char* local = "--local";
|
const char* local = "--local";
|
||||||
::wantLocalDomain = cmdOptionExists(argc, argv,local);
|
::wantLocalDomain = cmdOptionExists(argc, argv,local);
|
||||||
if (::wantLocalDomain) {
|
if (::wantLocalDomain) {
|
||||||
printf("Local Domain MODE!\n");
|
printf("Local Domain MODE!\n");
|
||||||
int ip = getLocalAddress();
|
nodeList->setDomainIPToLocalhost();
|
||||||
sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AUDIO_MIXER, MIXER_LISTEN_PORT);
|
|
||||||
|
|
||||||
ssize_t receivedBytes = 0;
|
ssize_t receivedBytes = 0;
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,7 @@ int main(int argc, const char* argv[]) {
|
||||||
const char* local = "--local";
|
const char* local = "--local";
|
||||||
if (cmdOptionExists(argc, argv, local)) {
|
if (cmdOptionExists(argc, argv, local)) {
|
||||||
printf("Local Domain MODE!\n");
|
printf("Local Domain MODE!\n");
|
||||||
int ip = getLocalAddress();
|
nodeList->setDomainIPToLocalhost();
|
||||||
sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeList->linkedDataCreateCallback = attachAvatarDataToNode;
|
nodeList->linkedDataCreateCallback = attachAvatarDataToNode;
|
||||||
|
|
|
@ -227,14 +227,14 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
|
|
||||||
const char* domainIP = getCmdOption(argc, constArgv, "--domain");
|
const char* domainIP = getCmdOption(argc, constArgv, "--domain");
|
||||||
if (domainIP) {
|
if (domainIP) {
|
||||||
strcpy(DOMAIN_IP, domainIP);
|
NodeList::getInstance()->setDomainIP(domainIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Local Domain testing with the --local command line
|
// Handle Local Domain testing with the --local command line
|
||||||
if (cmdOptionExists(argc, constArgv, "--local")) {
|
if (cmdOptionExists(argc, constArgv, "--local")) {
|
||||||
printLog("Local Domain MODE!\n");
|
printLog("Local Domain MODE!\n");
|
||||||
int ip = getLocalAddress();
|
|
||||||
sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF));
|
NodeList::getInstance()->setDomainIPToLocalhost();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if the user passed in a command line option for loading a local
|
// Check to see if the user passed in a command line option for loading a local
|
||||||
|
@ -1101,8 +1101,14 @@ void Application::editPreferences() {
|
||||||
QFormLayout* form = new QFormLayout();
|
QFormLayout* form = new QFormLayout();
|
||||||
layout->addLayout(form, 1);
|
layout->addLayout(form, 1);
|
||||||
|
|
||||||
|
const int QLINE_MINIMUM_WIDTH = 400;
|
||||||
|
|
||||||
|
QLineEdit* domainServerHostname = new QLineEdit(QString(NodeList::getInstance()->getDomainHostname()));
|
||||||
|
domainServerHostname->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||||
|
form->addRow("Domain server:", domainServerHostname);
|
||||||
|
|
||||||
QLineEdit* avatarURL = new QLineEdit(_myAvatar.getVoxels()->getVoxelURL().toString());
|
QLineEdit* avatarURL = new QLineEdit(_myAvatar.getVoxels()->getVoxelURL().toString());
|
||||||
avatarURL->setMinimumWidth(400);
|
avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||||
form->addRow("Avatar URL:", avatarURL);
|
form->addRow("Avatar URL:", avatarURL);
|
||||||
|
|
||||||
QSpinBox* horizontalFieldOfView = new QSpinBox();
|
QSpinBox* horizontalFieldOfView = new QSpinBox();
|
||||||
|
@ -1133,9 +1139,11 @@ void Application::editPreferences() {
|
||||||
if (dialog.exec() != QDialog::Accepted) {
|
if (dialog.exec() != QDialog::Accepted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl url(avatarURL->text());
|
QUrl url(avatarURL->text());
|
||||||
_myAvatar.getVoxels()->setVoxelURL(url);
|
_myAvatar.getVoxels()->setVoxelURL(url);
|
||||||
sendAvatarVoxelURLMessage(url);
|
sendAvatarVoxelURLMessage(url);
|
||||||
|
|
||||||
_headCameraPitchYawScale = headCameraPitchYawScale->value();
|
_headCameraPitchYawScale = headCameraPitchYawScale->value();
|
||||||
_myAvatar.setLeanScale(leanScale->value());
|
_myAvatar.setLeanScale(leanScale->value());
|
||||||
_audioJitterBufferSamples = audioJitterBufferSamples->value();
|
_audioJitterBufferSamples = audioJitterBufferSamples->value();
|
||||||
|
@ -1956,8 +1964,8 @@ void Application::update(float deltaTime) {
|
||||||
|
|
||||||
//loop through all the other avatars and simulate them...
|
//loop through all the other avatars and simulate them...
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
nodeList->lock();
|
|
||||||
for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||||
|
node->lock();
|
||||||
if (node->getLinkedData() != NULL) {
|
if (node->getLinkedData() != NULL) {
|
||||||
Avatar *avatar = (Avatar *)node->getLinkedData();
|
Avatar *avatar = (Avatar *)node->getLinkedData();
|
||||||
if (!avatar->isInitialized()) {
|
if (!avatar->isInitialized()) {
|
||||||
|
@ -1966,8 +1974,8 @@ void Application::update(float deltaTime) {
|
||||||
avatar->simulate(deltaTime, NULL);
|
avatar->simulate(deltaTime, NULL);
|
||||||
avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
|
avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
|
||||||
}
|
}
|
||||||
|
node->unlock();
|
||||||
}
|
}
|
||||||
nodeList->unlock();
|
|
||||||
|
|
||||||
// Simulate myself
|
// Simulate myself
|
||||||
if (_gravityUse->isChecked()) {
|
if (_gravityUse->isChecked()) {
|
||||||
|
@ -2456,8 +2464,10 @@ void Application::displaySide(Camera& whichCamera) {
|
||||||
if (_renderAvatarsOn->isChecked()) {
|
if (_renderAvatarsOn->isChecked()) {
|
||||||
// Render avatars of other nodes
|
// Render avatars of other nodes
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
nodeList->lock();
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||||
|
node->lock();
|
||||||
|
|
||||||
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
||||||
Avatar *avatar = (Avatar *)node->getLinkedData();
|
Avatar *avatar = (Avatar *)node->getLinkedData();
|
||||||
if (!avatar->isInitialized()) {
|
if (!avatar->isInitialized()) {
|
||||||
|
@ -2466,8 +2476,9 @@ void Application::displaySide(Camera& whichCamera) {
|
||||||
avatar->render(false, _renderAvatarBalls->isChecked());
|
avatar->render(false, _renderAvatarBalls->isChecked());
|
||||||
avatar->setDisplayingLookatVectors(_renderLookatOn->isChecked());
|
avatar->setDisplayingLookatVectors(_renderLookatOn->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node->unlock();
|
||||||
}
|
}
|
||||||
nodeList->unlock();
|
|
||||||
|
|
||||||
// Render my own Avatar
|
// Render my own Avatar
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
|
|
|
@ -126,8 +126,8 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
|
||||||
dataPacket,
|
dataPacket,
|
||||||
BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes);
|
BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes);
|
||||||
|
|
||||||
interface->getBandwidthMeter()->outputStream(BandwidthMeter::AUDIO)
|
interface->getBandwidthMeter()->outputStream(BandwidthMeter::AUDIO).updateValue(BUFFER_LENGTH_BYTES_PER_CHANNEL
|
||||||
.updateValue(BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes);
|
+ leadingBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,8 @@ Node::Node(sockaddr* publicSocket, sockaddr* localSocket, char type, uint16_t no
|
||||||
} else {
|
} else {
|
||||||
_localSocket = NULL;
|
_localSocket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_init(&mutex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::~Node() {
|
Node::~Node() {
|
||||||
|
@ -60,6 +62,8 @@ Node::~Node() {
|
||||||
delete _localSocket;
|
delete _localSocket;
|
||||||
delete _linkedData;
|
delete _linkedData;
|
||||||
delete _bytesReceivedMovingAverage;
|
delete _bytesReceivedMovingAverage;
|
||||||
|
|
||||||
|
pthread_mutex_destroy(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Names of Node Types
|
// Names of Node Types
|
||||||
|
|
|
@ -65,6 +65,9 @@ public:
|
||||||
|
|
||||||
int getPingMs() const { return _pingMs; };
|
int getPingMs() const { return _pingMs; };
|
||||||
void setPingMs(int pingMs) { _pingMs = pingMs; };
|
void setPingMs(int pingMs) { _pingMs = pingMs; };
|
||||||
|
|
||||||
|
void lock() { pthread_mutex_lock(&mutex); }
|
||||||
|
void unlock() { pthread_mutex_unlock(&mutex); }
|
||||||
|
|
||||||
static void printLog(Node const&);
|
static void printLog(Node const&);
|
||||||
private:
|
private:
|
||||||
|
@ -83,6 +86,7 @@ private:
|
||||||
NodeData* _linkedData;
|
NodeData* _linkedData;
|
||||||
bool _isAlive;
|
bool _isAlive;
|
||||||
int _pingMs;
|
int _pingMs;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@ const char SOLO_NODE_TYPES[3] = {
|
||||||
NODE_TYPE_VOXEL_SERVER
|
NODE_TYPE_VOXEL_SERVER
|
||||||
};
|
};
|
||||||
|
|
||||||
char DOMAIN_HOSTNAME[] = "highfidelity.below92.com";
|
const char DEFAULT_DOMAIN_HOSTNAME[MAX_HOSTNAME_BYTES] = "root.highfidelity.io";
|
||||||
char DOMAIN_IP[100] = ""; // IP Address will be re-set by lookup on startup
|
const char DEFAULT_DOMAIN_IP[INET_ADDRSTRLEN] = ""; // IP Address will be re-set by lookup on startup
|
||||||
const int DOMAINSERVER_PORT = 40102;
|
const int DEFAULT_DOMAINSERVER_PORT = 40102;
|
||||||
|
|
||||||
bool silentNodeThreadStopFlag = false;
|
bool silentNodeThreadStopFlag = false;
|
||||||
bool pingUnknownNodeThreadStopFlag = false;
|
bool pingUnknownNodeThreadStopFlag = false;
|
||||||
|
@ -63,8 +63,10 @@ NodeList::NodeList(char newOwnerType, unsigned int newSocketListenPort) :
|
||||||
_ownerType(newOwnerType),
|
_ownerType(newOwnerType),
|
||||||
_nodeTypesOfInterest(NULL),
|
_nodeTypesOfInterest(NULL),
|
||||||
_ownerID(UNKNOWN_NODE_ID),
|
_ownerID(UNKNOWN_NODE_ID),
|
||||||
_lastNodeID(0) {
|
_lastNodeID(0)
|
||||||
pthread_mutex_init(&mutex, 0);
|
{
|
||||||
|
memcpy(_domainHostname, DEFAULT_DOMAIN_HOSTNAME, sizeof(DEFAULT_DOMAIN_HOSTNAME));
|
||||||
|
memcpy(_domainIP, DEFAULT_DOMAIN_IP, sizeof(DEFAULT_DOMAIN_IP));
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList::~NodeList() {
|
NodeList::~NodeList() {
|
||||||
|
@ -74,8 +76,19 @@ NodeList::~NodeList() {
|
||||||
|
|
||||||
// stop the spawned threads, if they were started
|
// stop the spawned threads, if they were started
|
||||||
stopSilentNodeRemovalThread();
|
stopSilentNodeRemovalThread();
|
||||||
|
}
|
||||||
pthread_mutex_destroy(&mutex);
|
|
||||||
|
void NodeList::setDomainHostname(const char* domainHostname) {
|
||||||
|
memcpy(_domainHostname, domainHostname, sizeof(&domainHostname));
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeList::setDomainIP(const char* domainIP) {
|
||||||
|
memcpy(_domainIP, domainIP, sizeof(&domainIP));
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeList::setDomainIPToLocalhost() {
|
||||||
|
int ip = getLocalAddress();
|
||||||
|
sprintf(_domainIP, "%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::timePingReply(sockaddr *nodeAddress, unsigned char *packetData) {
|
void NodeList::timePingReply(sockaddr *nodeAddress, unsigned char *packetData) {
|
||||||
|
@ -112,7 +125,6 @@ void NodeList::processNodeData(sockaddr* senderAddress, unsigned char* packetDat
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::processBulkNodeData(sockaddr *senderAddress, unsigned char *packetData, int numTotalBytes) {
|
void NodeList::processBulkNodeData(sockaddr *senderAddress, unsigned char *packetData, int numTotalBytes) {
|
||||||
lock();
|
|
||||||
|
|
||||||
// find the avatar mixer in our node list and update the lastRecvTime from it
|
// find the avatar mixer in our node list and update the lastRecvTime from it
|
||||||
Node* bulkSendNode = nodeWithAddress(senderAddress);
|
Node* bulkSendNode = nodeWithAddress(senderAddress);
|
||||||
|
@ -149,9 +161,8 @@ void NodeList::processBulkNodeData(sockaddr *senderAddress, unsigned char *packe
|
||||||
currentPosition += updateNodeWithData(matchingNode,
|
currentPosition += updateNodeWithData(matchingNode,
|
||||||
packetHolder,
|
packetHolder,
|
||||||
numTotalBytes - (currentPosition - startPosition));
|
numTotalBytes - (currentPosition - startPosition));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int NodeList::updateNodeWithData(sockaddr *senderAddress, unsigned char *packetData, size_t dataBytes) {
|
int NodeList::updateNodeWithData(sockaddr *senderAddress, unsigned char *packetData, size_t dataBytes) {
|
||||||
|
@ -166,6 +177,8 @@ int NodeList::updateNodeWithData(sockaddr *senderAddress, unsigned char *packetD
|
||||||
}
|
}
|
||||||
|
|
||||||
int NodeList::updateNodeWithData(Node *node, unsigned char *packetData, int dataBytes) {
|
int NodeList::updateNodeWithData(Node *node, unsigned char *packetData, int dataBytes) {
|
||||||
|
node->lock();
|
||||||
|
|
||||||
node->setLastHeardMicrostamp(usecTimestampNow());
|
node->setLastHeardMicrostamp(usecTimestampNow());
|
||||||
|
|
||||||
if (node->getActiveSocket()) {
|
if (node->getActiveSocket()) {
|
||||||
|
@ -176,7 +189,11 @@ int NodeList::updateNodeWithData(Node *node, unsigned char *packetData, int data
|
||||||
linkedDataCreateCallback(node);
|
linkedDataCreateCallback(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
return node->getLinkedData()->parseData(packetData, dataBytes);
|
int numParsedBytes = node->getLinkedData()->parseData(packetData, dataBytes);
|
||||||
|
|
||||||
|
node->unlock();
|
||||||
|
|
||||||
|
return numParsedBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* NodeList::nodeWithAddress(sockaddr *senderAddress) {
|
Node* NodeList::nodeWithAddress(sockaddr *senderAddress) {
|
||||||
|
@ -236,18 +253,18 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
static bool printedDomainServerIP = false;
|
static bool printedDomainServerIP = false;
|
||||||
|
|
||||||
// Lookup the IP address of the domain server if we need to
|
// Lookup the IP address of the domain server if we need to
|
||||||
if (atoi(DOMAIN_IP) == 0) {
|
if (atoi(_domainIP) == 0) {
|
||||||
struct hostent* pHostInfo;
|
struct hostent* pHostInfo;
|
||||||
if ((pHostInfo = gethostbyname(DOMAIN_HOSTNAME)) != NULL) {
|
if ((pHostInfo = gethostbyname(_domainHostname)) != NULL) {
|
||||||
sockaddr_in tempAddress;
|
sockaddr_in tempAddress;
|
||||||
memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
|
memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
|
||||||
strcpy(DOMAIN_IP, inet_ntoa(tempAddress.sin_addr));
|
strcpy(_domainIP, inet_ntoa(tempAddress.sin_addr));
|
||||||
printLog("Domain Server: %s \n", DOMAIN_HOSTNAME);
|
printLog("Domain Server: %s \n", _domainHostname);
|
||||||
} else {
|
} else {
|
||||||
printLog("Failed domain server lookup\n");
|
printLog("Failed domain server lookup\n");
|
||||||
}
|
}
|
||||||
} else if (!printedDomainServerIP) {
|
} else if (!printedDomainServerIP) {
|
||||||
printLog("Domain Server IP: %s\n", DOMAIN_IP);
|
printLog("Domain Server IP: %s\n", _domainIP);
|
||||||
printedDomainServerIP = true;
|
printedDomainServerIP = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +311,7 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
checkInPacketSize = packetPosition - checkInPacket;
|
checkInPacketSize = packetPosition - checkInPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
_nodeSocket.send(DOMAIN_IP, DOMAINSERVER_PORT, checkInPacket, checkInPacketSize);
|
_nodeSocket.send(_domainIP, DEFAULT_DOMAINSERVER_PORT, checkInPacket, checkInPacketSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int NodeList::processDomainServerList(unsigned char* packetData, size_t dataBytes) {
|
int NodeList::processDomainServerList(unsigned char* packetData, size_t dataBytes) {
|
||||||
|
|
|
@ -9,8 +9,10 @@
|
||||||
#ifndef __hifi__NodeList__
|
#ifndef __hifi__NodeList__
|
||||||
#define __hifi__NodeList__
|
#define __hifi__NodeList__
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
#include "UDPSocket.h"
|
#include "UDPSocket.h"
|
||||||
|
@ -30,9 +32,11 @@ const int DOMAIN_SERVER_CHECK_IN_USECS = 1 * 1000000;
|
||||||
|
|
||||||
extern const char SOLO_NODE_TYPES[3];
|
extern const char SOLO_NODE_TYPES[3];
|
||||||
|
|
||||||
extern char DOMAIN_HOSTNAME[];
|
const int MAX_HOSTNAME_BYTES = 255;
|
||||||
extern char DOMAIN_IP[100]; // IP Address will be re-set by lookup on startup
|
|
||||||
extern const int DOMAINSERVER_PORT;
|
extern const char DEFAULT_DOMAIN_HOSTNAME[MAX_HOSTNAME_BYTES];
|
||||||
|
extern const char DEFAULT_DOMAIN_IP[INET_ADDRSTRLEN]; // IP Address will be re-set by lookup on startup
|
||||||
|
extern const int DEFAULT_DOMAINSERVER_PORT;
|
||||||
|
|
||||||
const int UNKNOWN_NODE_ID = -1;
|
const int UNKNOWN_NODE_ID = -1;
|
||||||
|
|
||||||
|
@ -48,6 +52,12 @@ public:
|
||||||
NodeListIterator begin() const;
|
NodeListIterator begin() const;
|
||||||
NodeListIterator end() const;
|
NodeListIterator end() const;
|
||||||
|
|
||||||
|
const char* getDomainHostname() const { return _domainHostname; };
|
||||||
|
void setDomainHostname(const char* domainHostname);
|
||||||
|
|
||||||
|
void setDomainIP(const char* domainIP);
|
||||||
|
void setDomainIPToLocalhost();
|
||||||
|
|
||||||
char getOwnerType() const { return _ownerType; }
|
char getOwnerType() const { return _ownerType; }
|
||||||
|
|
||||||
uint16_t getLastNodeID() const { return _lastNodeID; }
|
uint16_t getLastNodeID() const { return _lastNodeID; }
|
||||||
|
@ -67,9 +77,6 @@ public:
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void lock() { pthread_mutex_lock(&mutex); }
|
|
||||||
void unlock() { pthread_mutex_unlock(&mutex); }
|
|
||||||
|
|
||||||
void setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest);
|
void setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest);
|
||||||
void sendDomainServerCheckIn();
|
void sendDomainServerCheckIn();
|
||||||
int processDomainServerList(unsigned char *packetData, size_t dataBytes);
|
int processDomainServerList(unsigned char *packetData, size_t dataBytes);
|
||||||
|
@ -103,6 +110,8 @@ private:
|
||||||
|
|
||||||
void addNodeToList(Node* newNode);
|
void addNodeToList(Node* newNode);
|
||||||
|
|
||||||
|
char _domainHostname[MAX_HOSTNAME_BYTES];
|
||||||
|
char _domainIP[INET_ADDRSTRLEN];
|
||||||
Node** _nodeBuckets[MAX_NUM_NODES / NODES_PER_BUCKET];
|
Node** _nodeBuckets[MAX_NUM_NODES / NODES_PER_BUCKET];
|
||||||
int _numNodes;
|
int _numNodes;
|
||||||
UDPSocket _nodeSocket;
|
UDPSocket _nodeSocket;
|
||||||
|
@ -113,7 +122,6 @@ private:
|
||||||
uint16_t _lastNodeID;
|
uint16_t _lastNodeID;
|
||||||
pthread_t removeSilentNodesThread;
|
pthread_t removeSilentNodesThread;
|
||||||
pthread_t checkInWithDomainServerThread;
|
pthread_t checkInWithDomainServerThread;
|
||||||
pthread_mutex_t mutex;
|
|
||||||
|
|
||||||
void handlePingReply(sockaddr *nodeAddress);
|
void handlePingReply(sockaddr *nodeAddress);
|
||||||
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
||||||
|
|
|
@ -383,8 +383,7 @@ int main(int argc, const char * argv[]) {
|
||||||
::wantLocalDomain = cmdOptionExists(argc, argv,local);
|
::wantLocalDomain = cmdOptionExists(argc, argv,local);
|
||||||
if (::wantLocalDomain) {
|
if (::wantLocalDomain) {
|
||||||
printf("Local Domain MODE!\n");
|
printf("Local Domain MODE!\n");
|
||||||
int ip = getLocalAddress();
|
nodeList->setDomainIPToLocalhost();
|
||||||
sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeList->linkedDataCreateCallback = &attachVoxelNodeDataToNode;
|
nodeList->linkedDataCreateCallback = &attachVoxelNodeDataToNode;
|
||||||
|
|
Loading…
Reference in a new issue