mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 12:09:52 +02:00
don't send create assignment request until connection to DS
This commit is contained in:
parent
774eef1c12
commit
b3bd159d09
2 changed files with 46 additions and 29 deletions
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
#include <Logging.h>
|
#include <Logging.h>
|
||||||
#include <OctalCode.h>
|
#include <OctalCode.h>
|
||||||
|
@ -50,7 +49,8 @@ void attachVoxelNodeDataToNode(Node* newNode) {
|
||||||
|
|
||||||
VoxelServer::VoxelServer(Assignment::Command command, Assignment::Location location) :
|
VoxelServer::VoxelServer(Assignment::Command command, Assignment::Location location) :
|
||||||
Assignment(command, Assignment::VoxelServerType, location),
|
Assignment(command, Assignment::VoxelServerType, location),
|
||||||
_serverTree(true) {
|
_serverTree(true),
|
||||||
|
_multiConfigList() {
|
||||||
_argc = 0;
|
_argc = 0;
|
||||||
_argv = NULL;
|
_argv = NULL;
|
||||||
|
|
||||||
|
@ -72,7 +72,8 @@ VoxelServer::VoxelServer(Assignment::Command command, Assignment::Location locat
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assignment(dataBuffer, numBytes),
|
VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assignment(dataBuffer, numBytes),
|
||||||
_serverTree(true) {
|
_serverTree(true),
|
||||||
|
_multiConfigList() {
|
||||||
_argc = 0;
|
_argc = 0;
|
||||||
_argv = NULL;
|
_argv = NULL;
|
||||||
|
|
||||||
|
@ -116,34 +117,11 @@ void VoxelServer::setArguments(int argc, char** argv) {
|
||||||
void VoxelServer::parsePayload() {
|
void VoxelServer::parsePayload() {
|
||||||
|
|
||||||
if (getNumPayloadBytes() > 0) {
|
if (getNumPayloadBytes() > 0) {
|
||||||
QString multiConfig((const char*)getPayload());
|
QString multiConfig((const char*) _payload);
|
||||||
QStringList multiConfigList = multiConfig.split(";");
|
_multiConfigList = multiConfig.split(";");
|
||||||
|
|
||||||
// There there are multiple configs, then this instance will run the first
|
|
||||||
// config, and launch Assignment requests for the additional configs.
|
|
||||||
if (multiConfigList.size() > 1) {
|
|
||||||
qDebug("Voxel Server received assignment for multiple Configs... config count=%d\n", multiConfigList.size());
|
|
||||||
|
|
||||||
// skip 0 - that's the one we'll run
|
|
||||||
for (int i = 1; i < multiConfigList.size(); i++) {
|
|
||||||
QString config = multiConfigList.at(i);
|
|
||||||
|
|
||||||
qDebug(" config[%d]=%s\n", i, config.toLocal8Bit().constData());
|
|
||||||
|
|
||||||
Assignment voxelServerAssignment(Assignment::CreateCommand,
|
|
||||||
Assignment::VoxelServerType,
|
|
||||||
getLocation()); // use same location as we were created in.
|
|
||||||
|
|
||||||
int payloadLength = config.length() + sizeof(char);
|
|
||||||
voxelServerAssignment.setPayload((uchar*)config.toLocal8Bit().constData(), payloadLength);
|
|
||||||
|
|
||||||
qDebug("Requesting additional Voxel Server assignment to handle config %d\n", i);
|
|
||||||
NodeList::getInstance()->sendAssignment(voxelServerAssignment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now, parse the first config
|
// Now, parse the first config
|
||||||
QString config = multiConfigList.at(0);
|
QString config = _multiConfigList.at(0);
|
||||||
QStringList configList = config.split(" ");
|
QStringList configList = config.split(" ");
|
||||||
|
|
||||||
int argCount = configList.size() + 1;
|
int argCount = configList.size() + 1;
|
||||||
|
@ -166,6 +144,31 @@ void VoxelServer::parsePayload() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoxelServer::parseOtherServerConfigs() {
|
||||||
|
// There there are multiple configs, then this instance will run the first
|
||||||
|
// config, and launch Assignment requests for the additional configs.
|
||||||
|
if (_multiConfigList.size() > 1) {
|
||||||
|
qDebug("Voxel Server received assignment for multiple Configs... config count=%d\n", _multiConfigList.size());
|
||||||
|
|
||||||
|
// skip 0 - that's the one we'll run
|
||||||
|
for (int i = 1; i < _multiConfigList.size(); i++) {
|
||||||
|
QString config = _multiConfigList.at(i);
|
||||||
|
|
||||||
|
qDebug(" config[%d]=%s\n", i, config.toLocal8Bit().constData());
|
||||||
|
|
||||||
|
Assignment voxelServerAssignment(Assignment::CreateCommand,
|
||||||
|
Assignment::VoxelServerType,
|
||||||
|
getLocation()); // use same location as we were created in.
|
||||||
|
|
||||||
|
int payloadLength = config.length() + sizeof(char);
|
||||||
|
voxelServerAssignment.setPayload((uchar*)config.toLocal8Bit().constData(), payloadLength);
|
||||||
|
|
||||||
|
qDebug("Requesting additional Voxel Server assignment to handle config %d\n", i);
|
||||||
|
NodeList::getInstance()->sendAssignment(voxelServerAssignment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//int main(int argc, const char * argv[]) {
|
//int main(int argc, const char * argv[]) {
|
||||||
void VoxelServer::run() {
|
void VoxelServer::run() {
|
||||||
|
|
||||||
|
@ -354,6 +357,8 @@ void VoxelServer::run() {
|
||||||
_voxelServerPacketProcessor->initialize(true);
|
_voxelServerPacketProcessor->initialize(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isFirstDomainPacket = true;
|
||||||
|
|
||||||
// loop to send to nodes requesting data
|
// loop to send to nodes requesting data
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
|
@ -393,6 +398,14 @@ void VoxelServer::run() {
|
||||||
// If the packet is a ping, let processNodeData handle it.
|
// If the packet is a ping, let processNodeData handle it.
|
||||||
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
||||||
} else if (packetData[0] == PACKET_TYPE_DOMAIN) {
|
} else if (packetData[0] == PACKET_TYPE_DOMAIN) {
|
||||||
|
|
||||||
|
if (isFirstDomainPacket) {
|
||||||
|
// this is the first packet we've received from the DS, parse the other server configs
|
||||||
|
// so we can make the appropriate create assignment requests
|
||||||
|
parseOtherServerConfigs();
|
||||||
|
isFirstDomainPacket = false;
|
||||||
|
}
|
||||||
|
|
||||||
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
NodeList::getInstance()->processNodeData(&senderAddress, packetData, packetLength);
|
||||||
} else if (packetData[0] == PACKET_TYPE_VOXEL_JURISDICTION_REQUEST) {
|
} else if (packetData[0] == PACKET_TYPE_VOXEL_JURISDICTION_REQUEST) {
|
||||||
if (_jurisdictionSender) {
|
if (_jurisdictionSender) {
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#ifndef __voxel_server__VoxelServer__
|
#ifndef __voxel_server__VoxelServer__
|
||||||
#define __voxel_server__VoxelServer__
|
#define __voxel_server__VoxelServer__
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include <Assignment.h>
|
#include <Assignment.h>
|
||||||
#include <EnvironmentData.h>
|
#include <EnvironmentData.h>
|
||||||
|
|
||||||
|
@ -78,8 +80,10 @@ private:
|
||||||
EnvironmentData _environmentData[3];
|
EnvironmentData _environmentData[3];
|
||||||
|
|
||||||
NodeWatcher _nodeWatcher; // used to cleanup AGENT data when agents are killed
|
NodeWatcher _nodeWatcher; // used to cleanup AGENT data when agents are killed
|
||||||
|
QStringList _multiConfigList;
|
||||||
|
|
||||||
void parsePayload();
|
void parsePayload();
|
||||||
|
void parseOtherServerConfigs();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __voxel_server__VoxelServer__
|
#endif // __voxel_server__VoxelServer__
|
||||||
|
|
Loading…
Reference in a new issue