mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:17:02 +02:00
use safer domain-server settings request in entity-server
This commit is contained in:
parent
eafc11e054
commit
20485b817c
6 changed files with 49 additions and 68 deletions
|
@ -647,14 +647,12 @@ void AudioMixer::run() {
|
||||||
|
|
||||||
qDebug() << "Waiting for connection to domain to request settings from domain-server.";
|
qDebug() << "Waiting for connection to domain to request settings from domain-server.";
|
||||||
|
|
||||||
ThreadedAssignment::commonInit(AUDIO_MIXER_LOGGING_TARGET_NAME, NodeType::AudioMixer);
|
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
|
||||||
|
|
||||||
// wait until we have the domain-server settings, otherwise we bail
|
// wait until we have the domain-server settings, otherwise we bail
|
||||||
DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||||
connect(&domainHandler, &DomainHandler::settingsReceived, this, &AudioMixer::domainSettingsRequestComplete);
|
connect(&domainHandler, &DomainHandler::settingsReceived, this, &AudioMixer::domainSettingsRequestComplete);
|
||||||
connect(&domainHandler, &DomainHandler::settingsReceiveFail, this, &AudioMixer::domainSettingsRequestFailed);
|
connect(&domainHandler, &DomainHandler::settingsReceiveFail, this, &AudioMixer::domainSettingsRequestFailed);
|
||||||
|
|
||||||
|
ThreadedAssignment::commonInit(AUDIO_MIXER_LOGGING_TARGET_NAME, NodeType::AudioMixer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioMixer::domainSettingsRequestComplete() {
|
void AudioMixer::domainSettingsRequestComplete() {
|
||||||
|
|
|
@ -514,6 +514,11 @@ void AvatarMixer::sendStatsPacket() {
|
||||||
void AvatarMixer::run() {
|
void AvatarMixer::run() {
|
||||||
qDebug() << "Waiting for connection to domain to request settings from domain-server.";
|
qDebug() << "Waiting for connection to domain to request settings from domain-server.";
|
||||||
|
|
||||||
|
// wait until we have the domain-server settings, otherwise we bail
|
||||||
|
DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||||
|
connect(&domainHandler, &DomainHandler::settingsReceived, this, &AvatarMixer::domainSettingsRequestComplete);
|
||||||
|
connect(&domainHandler, &DomainHandler::settingsReceiveFail, this, &AvatarMixer::domainSettingsRequestFailed);
|
||||||
|
|
||||||
ThreadedAssignment::commonInit(AVATAR_MIXER_LOGGING_NAME, NodeType::AvatarMixer);
|
ThreadedAssignment::commonInit(AVATAR_MIXER_LOGGING_NAME, NodeType::AvatarMixer);
|
||||||
|
|
||||||
// setup the timer that will be fired on the broadcast thread
|
// setup the timer that will be fired on the broadcast thread
|
||||||
|
@ -524,11 +529,6 @@ void AvatarMixer::run() {
|
||||||
// connect appropriate signals and slots
|
// connect appropriate signals and slots
|
||||||
connect(_broadcastTimer, &QTimer::timeout, this, &AvatarMixer::broadcastAvatarData, Qt::DirectConnection);
|
connect(_broadcastTimer, &QTimer::timeout, this, &AvatarMixer::broadcastAvatarData, Qt::DirectConnection);
|
||||||
connect(&_broadcastThread, SIGNAL(started()), _broadcastTimer, SLOT(start()));
|
connect(&_broadcastThread, SIGNAL(started()), _broadcastTimer, SLOT(start()));
|
||||||
|
|
||||||
// wait until we have the domain-server settings, otherwise we bail
|
|
||||||
DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
|
||||||
connect(&domainHandler, &DomainHandler::settingsReceived, this, &AvatarMixer::domainSettingsRequestComplete);
|
|
||||||
connect(&domainHandler, &DomainHandler::settingsReceiveFail, this, &AvatarMixer::domainSettingsRequestFailed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarMixer::domainSettingsRequestComplete() {
|
void AvatarMixer::domainSettingsRequestComplete() {
|
||||||
|
|
|
@ -253,7 +253,7 @@ void EntityServer::pruneDeletedEntities() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityServer::readAdditionalConfiguration(const QJsonObject& settingsSectionObject) {
|
void EntityServer::readAdditionalConfiguration(const QJsonObject& settingsSectionObject) {
|
||||||
bool wantEditLogging = false;
|
bool wantEditLogging = false;
|
||||||
readOptionBool(QString("wantEditLogging"), settingsSectionObject, wantEditLogging);
|
readOptionBool(QString("wantEditLogging"), settingsSectionObject, wantEditLogging);
|
||||||
qDebug("wantEditLogging=%s", debug::valueOf(wantEditLogging));
|
qDebug("wantEditLogging=%s", debug::valueOf(wantEditLogging));
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
virtual int sendSpecialPackets(const SharedNodePointer& node, OctreeQueryNode* queryNode, int& packetsSent) override;
|
virtual int sendSpecialPackets(const SharedNodePointer& node, OctreeQueryNode* queryNode, int& packetsSent) override;
|
||||||
|
|
||||||
virtual void entityCreated(const EntityItem& newEntity, const SharedNodePointer& senderNode) override;
|
virtual void entityCreated(const EntityItem& newEntity, const SharedNodePointer& senderNode) override;
|
||||||
virtual bool readAdditionalConfiguration(const QJsonObject& settingsSectionObject) override;
|
virtual void readAdditionalConfiguration(const QJsonObject& settingsSectionObject) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void pruneDeletedEntities();
|
void pruneDeletedEntities();
|
||||||
|
|
|
@ -932,32 +932,13 @@ bool OctreeServer::readOptionString(const QString& optionName, const QJsonObject
|
||||||
return optionAvailable;
|
return optionAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OctreeServer::readConfiguration() {
|
void OctreeServer::readConfiguration() {
|
||||||
// if the assignment had a payload, read and parse that
|
// if the assignment had a payload, read and parse that
|
||||||
if (getPayload().size() > 0) {
|
if (getPayload().size() > 0) {
|
||||||
parsePayload();
|
parsePayload();
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait until we have the domain-server settings, otherwise we bail
|
const QJsonObject& settingsObject = DependencyManager::get<NodeList>()->getDomainHandler().getSettingsObject();
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
|
||||||
DomainHandler& domainHandler = nodeList->getDomainHandler();
|
|
||||||
|
|
||||||
qDebug() << "Waiting for domain settings from domain-server.";
|
|
||||||
|
|
||||||
// block until we get the settingsRequestComplete signal
|
|
||||||
QEventLoop loop;
|
|
||||||
connect(&domainHandler, &DomainHandler::settingsReceived, &loop, &QEventLoop::quit);
|
|
||||||
connect(&domainHandler, &DomainHandler::settingsReceiveFail, &loop, &QEventLoop::quit);
|
|
||||||
domainHandler.requestDomainSettings();
|
|
||||||
loop.exec();
|
|
||||||
|
|
||||||
if (domainHandler.getSettingsObject().isEmpty()) {
|
|
||||||
qDebug() << "Failed to retreive settings object from domain-server. Bailing on assignment.";
|
|
||||||
setFinished(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QJsonObject& settingsObject = domainHandler.getSettingsObject();
|
|
||||||
QString settingsKey = getMyDomainSettingsKey();
|
QString settingsKey = getMyDomainSettingsKey();
|
||||||
QJsonObject settingsSectionObject = settingsObject[settingsKey].toObject();
|
QJsonObject settingsSectionObject = settingsObject[settingsKey].toObject();
|
||||||
_settings = settingsSectionObject; // keep this for later
|
_settings = settingsSectionObject; // keep this for later
|
||||||
|
@ -1065,79 +1046,79 @@ bool OctreeServer::readConfiguration() {
|
||||||
packetsPerSecondTotalMax, _packetsTotalPerInterval);
|
packetsPerSecondTotalMax, _packetsTotalPerInterval);
|
||||||
|
|
||||||
|
|
||||||
return readAdditionalConfiguration(settingsSectionObject);
|
readAdditionalConfiguration(settingsSectionObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctreeServer::run() {
|
void OctreeServer::run() {
|
||||||
|
|
||||||
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
|
||||||
packetReceiver.registerListener(getMyQueryMessageType(), this, "handleOctreeQueryPacket");
|
|
||||||
packetReceiver.registerListener(PacketType::OctreeDataNack, this, "handleOctreeDataNackPacket");
|
|
||||||
packetReceiver.registerListener(PacketType::JurisdictionRequest, this, "handleJurisdictionRequestPacket");
|
|
||||||
|
|
||||||
_safeServerName = getMyServerName();
|
_safeServerName = getMyServerName();
|
||||||
|
|
||||||
// Before we do anything else, create our tree...
|
// Before we do anything else, create our tree...
|
||||||
OctreeElement::resetPopulationStatistics();
|
OctreeElement::resetPopulationStatistics();
|
||||||
_tree = createTree();
|
_tree = createTree();
|
||||||
_tree->setIsServer(true);
|
_tree->setIsServer(true);
|
||||||
|
|
||||||
// make sure our NodeList knows what type we are
|
qDebug() << "Waiting for connection to domain to request settings from domain-server.";
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
|
||||||
nodeList->setOwnerType(getMyNodeType());
|
// wait until we have the domain-server settings, otherwise we bail
|
||||||
|
DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||||
|
connect(&domainHandler, &DomainHandler::settingsReceived, this, &OctreeServer::domainSettingsRequestComplete);
|
||||||
|
connect(&domainHandler, &DomainHandler::settingsReceiveFail, this, &OctreeServer::domainSettingsRequestFailed);
|
||||||
|
|
||||||
// use common init to setup common timers and logging
|
// use common init to setup common timers and logging
|
||||||
commonInit(getMyLoggingServerTargetName(), getMyNodeType());
|
commonInit(getMyLoggingServerTargetName(), getMyNodeType());
|
||||||
|
}
|
||||||
|
|
||||||
// read the configuration from either the payload or the domain server configuration
|
void OctreeServer::domainSettingsRequestComplete() {
|
||||||
if (!readConfiguration()) {
|
|
||||||
return; // bailing on run, because readConfiguration failed
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
}
|
|
||||||
|
|
||||||
beforeRun(); // after payload has been processed
|
|
||||||
|
|
||||||
connect(nodeList.data(), SIGNAL(nodeAdded(SharedNodePointer)), SLOT(nodeAdded(SharedNodePointer)));
|
|
||||||
connect(nodeList.data(), SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
|
|
||||||
|
|
||||||
|
|
||||||
// we need to ask the DS about agents so we can ping/reply with them
|
// we need to ask the DS about agents so we can ping/reply with them
|
||||||
nodeList->addNodeTypeToInterestSet(NodeType::Agent);
|
nodeList->addNodeTypeToInterestSet(NodeType::Agent);
|
||||||
|
|
||||||
|
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
||||||
|
packetReceiver.registerListener(getMyQueryMessageType(), this, "handleOctreeQueryPacket");
|
||||||
|
packetReceiver.registerListener(PacketType::OctreeDataNack, this, "handleOctreeDataNackPacket");
|
||||||
|
packetReceiver.registerListener(PacketType::JurisdictionRequest, this, "handleJurisdictionRequestPacket");
|
||||||
|
|
||||||
|
readConfiguration();
|
||||||
|
|
||||||
|
beforeRun(); // after payload has been processed
|
||||||
|
|
||||||
|
connect(nodeList.data(), SIGNAL(nodeAdded(SharedNodePointer)), SLOT(nodeAdded(SharedNodePointer)));
|
||||||
|
connect(nodeList.data(), SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nodeList->linkedDataCreateCallback = [] (Node* node) {
|
nodeList->linkedDataCreateCallback = [] (Node* node) {
|
||||||
OctreeQueryNode* newQueryNodeData = _instance->createOctreeQueryNode();
|
OctreeQueryNode* newQueryNodeData = _instance->createOctreeQueryNode();
|
||||||
newQueryNodeData->init();
|
newQueryNodeData->init();
|
||||||
node->setLinkedData(newQueryNodeData);
|
node->setLinkedData(newQueryNodeData);
|
||||||
};
|
};
|
||||||
|
|
||||||
srand((unsigned)time(0));
|
srand((unsigned)time(0));
|
||||||
|
|
||||||
// if we want Persistence, set up the local file and persist thread
|
// if we want Persistence, set up the local file and persist thread
|
||||||
if (_wantPersist) {
|
if (_wantPersist) {
|
||||||
|
|
||||||
// now set up PersistThread
|
// now set up PersistThread
|
||||||
_persistThread = new OctreePersistThread(_tree, _persistFilename, _persistInterval,
|
_persistThread = new OctreePersistThread(_tree, _persistFilename, _persistInterval,
|
||||||
_wantBackup, _settings, _debugTimestampNow, _persistAsFileType);
|
_wantBackup, _settings, _debugTimestampNow, _persistAsFileType);
|
||||||
_persistThread->initialize(true);
|
_persistThread->initialize(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiSockAddr senderSockAddr;
|
|
||||||
|
|
||||||
// set up our jurisdiction broadcaster...
|
// set up our jurisdiction broadcaster...
|
||||||
if (_jurisdiction) {
|
if (_jurisdiction) {
|
||||||
_jurisdiction->setNodeType(getMyNodeType());
|
_jurisdiction->setNodeType(getMyNodeType());
|
||||||
}
|
}
|
||||||
_jurisdictionSender = new JurisdictionSender(_jurisdiction, getMyNodeType());
|
_jurisdictionSender = new JurisdictionSender(_jurisdiction, getMyNodeType());
|
||||||
_jurisdictionSender->initialize(true);
|
_jurisdictionSender->initialize(true);
|
||||||
|
|
||||||
// set up our OctreeServerPacketProcessor
|
// set up our OctreeServerPacketProcessor
|
||||||
_octreeInboundPacketProcessor = new OctreeInboundPacketProcessor(this);
|
_octreeInboundPacketProcessor = new OctreeInboundPacketProcessor(this);
|
||||||
_octreeInboundPacketProcessor->initialize(true);
|
_octreeInboundPacketProcessor->initialize(true);
|
||||||
|
|
||||||
// Convert now to tm struct for local timezone
|
// Convert now to tm struct for local timezone
|
||||||
tm* localtm = localtime(&_started);
|
tm* localtm = localtime(&_started);
|
||||||
const int MAX_TIME_LENGTH = 128;
|
const int MAX_TIME_LENGTH = 128;
|
||||||
|
@ -1149,6 +1130,7 @@ void OctreeServer::run() {
|
||||||
if (gmtm) {
|
if (gmtm) {
|
||||||
strftime(utcBuffer, MAX_TIME_LENGTH, " [%m/%d/%Y %X UTC]", gmtm);
|
strftime(utcBuffer, MAX_TIME_LENGTH, " [%m/%d/%Y %X UTC]", gmtm);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Now running... started at: " << localBuffer << utcBuffer;
|
qDebug() << "Now running... started at: " << localBuffer << utcBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,7 @@ public slots:
|
||||||
void sendStatsPacket();
|
void sendStatsPacket();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void domainSettingsRequestComplete();
|
||||||
void handleOctreeQueryPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
void handleOctreeQueryPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
||||||
void handleOctreeDataNackPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
void handleOctreeDataNackPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
||||||
void handleJurisdictionRequestPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
void handleJurisdictionRequestPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
||||||
|
@ -135,8 +136,8 @@ protected:
|
||||||
bool readOptionBool(const QString& optionName, const QJsonObject& settingsSectionObject, bool& result);
|
bool readOptionBool(const QString& optionName, const QJsonObject& settingsSectionObject, bool& result);
|
||||||
bool readOptionInt(const QString& optionName, const QJsonObject& settingsSectionObject, int& result);
|
bool readOptionInt(const QString& optionName, const QJsonObject& settingsSectionObject, int& result);
|
||||||
bool readOptionString(const QString& optionName, const QJsonObject& settingsSectionObject, QString& result);
|
bool readOptionString(const QString& optionName, const QJsonObject& settingsSectionObject, QString& result);
|
||||||
bool readConfiguration();
|
void readConfiguration();
|
||||||
virtual bool readAdditionalConfiguration(const QJsonObject& settingsSectionObject) { return true; };
|
virtual void readAdditionalConfiguration(const QJsonObject& settingsSectionObject) { };
|
||||||
void parsePayload();
|
void parsePayload();
|
||||||
void initHTTPManager(int port);
|
void initHTTPManager(int port);
|
||||||
void resetSendingStats();
|
void resetSendingStats();
|
||||||
|
|
Loading…
Reference in a new issue