mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:16:58 +02:00
Merge pull request #6425 from birarda/handshake-ds-settings
fix case where servers could run without settings
This commit is contained in:
commit
e318537af4
13 changed files with 166 additions and 170 deletions
|
@ -644,188 +644,187 @@ void AudioMixer::sendStatsPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioMixer::run() {
|
void AudioMixer::run() {
|
||||||
|
|
||||||
|
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, &AudioMixer::domainSettingsRequestComplete);
|
||||||
|
connect(&domainHandler, &DomainHandler::settingsReceiveFail, this, &AudioMixer::domainSettingsRequestFailed);
|
||||||
|
|
||||||
ThreadedAssignment::commonInit(AUDIO_MIXER_LOGGING_TARGET_NAME, NodeType::AudioMixer);
|
ThreadedAssignment::commonInit(AUDIO_MIXER_LOGGING_TARGET_NAME, NodeType::AudioMixer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioMixer::domainSettingsRequestComplete() {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
nodeList->addNodeTypeToInterestSet(NodeType::Agent);
|
nodeList->addNodeTypeToInterestSet(NodeType::Agent);
|
||||||
|
|
||||||
nodeList->linkedDataCreateCallback = [](Node* node) {
|
nodeList->linkedDataCreateCallback = [](Node* node) {
|
||||||
node->setLinkedData(new AudioMixerClientData());
|
node->setLinkedData(new AudioMixerClientData());
|
||||||
};
|
};
|
||||||
|
|
||||||
// wait until we have the domain-server settings, otherwise we bail
|
|
||||||
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()) {
|
DomainHandler& domainHandler = nodeList->getDomainHandler();
|
||||||
qDebug() << "Failed to retreive settings object from domain-server. Bailing on assignment.";
|
|
||||||
setFinished(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QJsonObject& settingsObject = domainHandler.getSettingsObject();
|
const QJsonObject& settingsObject = domainHandler.getSettingsObject();
|
||||||
|
|
||||||
// check the settings object to see if we have anything we can parse out
|
// check the settings object to see if we have anything we can parse out
|
||||||
parseSettingsObject(settingsObject);
|
parseSettingsObject(settingsObject);
|
||||||
|
|
||||||
|
// queue up a connection to start broadcasting mixes now that we're ready to go
|
||||||
|
QMetaObject::invokeMethod(this, "broadcastMixes", Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioMixer::broadcastMixes() {
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
int nextFrame = 0;
|
int nextFrame = 0;
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
int usecToSleep = AudioConstants::NETWORK_FRAME_USECS;
|
int usecToSleep = AudioConstants::NETWORK_FRAME_USECS;
|
||||||
|
|
||||||
const int TRAILING_AVERAGE_FRAMES = 100;
|
const int TRAILING_AVERAGE_FRAMES = 100;
|
||||||
int framesSinceCutoffEvent = TRAILING_AVERAGE_FRAMES;
|
int framesSinceCutoffEvent = TRAILING_AVERAGE_FRAMES;
|
||||||
|
|
||||||
while (!_isFinished) {
|
while (!_isFinished) {
|
||||||
const float STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.10f;
|
const float STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.10f;
|
||||||
const float BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.20f;
|
const float BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.20f;
|
||||||
|
|
||||||
const float RATIO_BACK_OFF = 0.02f;
|
const float RATIO_BACK_OFF = 0.02f;
|
||||||
|
|
||||||
const float CURRENT_FRAME_RATIO = 1.0f / TRAILING_AVERAGE_FRAMES;
|
const float CURRENT_FRAME_RATIO = 1.0f / TRAILING_AVERAGE_FRAMES;
|
||||||
const float PREVIOUS_FRAMES_RATIO = 1.0f - CURRENT_FRAME_RATIO;
|
const float PREVIOUS_FRAMES_RATIO = 1.0f - CURRENT_FRAME_RATIO;
|
||||||
|
|
||||||
if (usecToSleep < 0) {
|
if (usecToSleep < 0) {
|
||||||
usecToSleep = 0;
|
usecToSleep = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_trailingSleepRatio = (PREVIOUS_FRAMES_RATIO * _trailingSleepRatio)
|
_trailingSleepRatio = (PREVIOUS_FRAMES_RATIO * _trailingSleepRatio)
|
||||||
+ (usecToSleep * CURRENT_FRAME_RATIO / (float) AudioConstants::NETWORK_FRAME_USECS);
|
+ (usecToSleep * CURRENT_FRAME_RATIO / (float) AudioConstants::NETWORK_FRAME_USECS);
|
||||||
|
|
||||||
float lastCutoffRatio = _performanceThrottlingRatio;
|
float lastCutoffRatio = _performanceThrottlingRatio;
|
||||||
bool hasRatioChanged = false;
|
bool hasRatioChanged = false;
|
||||||
|
|
||||||
if (framesSinceCutoffEvent >= TRAILING_AVERAGE_FRAMES) {
|
if (framesSinceCutoffEvent >= TRAILING_AVERAGE_FRAMES) {
|
||||||
if (_trailingSleepRatio <= STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD) {
|
if (_trailingSleepRatio <= STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD) {
|
||||||
// we're struggling - change our min required loudness to reduce some load
|
// we're struggling - change our min required loudness to reduce some load
|
||||||
_performanceThrottlingRatio = _performanceThrottlingRatio + (0.5f * (1.0f - _performanceThrottlingRatio));
|
_performanceThrottlingRatio = _performanceThrottlingRatio + (0.5f * (1.0f - _performanceThrottlingRatio));
|
||||||
|
|
||||||
qDebug() << "Mixer is struggling, sleeping" << _trailingSleepRatio * 100 << "% of frame time. Old cutoff was"
|
qDebug() << "Mixer is struggling, sleeping" << _trailingSleepRatio * 100 << "% of frame time. Old cutoff was"
|
||||||
<< lastCutoffRatio << "and is now" << _performanceThrottlingRatio;
|
<< lastCutoffRatio << "and is now" << _performanceThrottlingRatio;
|
||||||
hasRatioChanged = true;
|
hasRatioChanged = true;
|
||||||
} else if (_trailingSleepRatio >= BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD && _performanceThrottlingRatio != 0) {
|
} else if (_trailingSleepRatio >= BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD && _performanceThrottlingRatio != 0) {
|
||||||
// we've recovered and can back off the required loudness
|
// we've recovered and can back off the required loudness
|
||||||
_performanceThrottlingRatio = _performanceThrottlingRatio - RATIO_BACK_OFF;
|
_performanceThrottlingRatio = _performanceThrottlingRatio - RATIO_BACK_OFF;
|
||||||
|
|
||||||
if (_performanceThrottlingRatio < 0) {
|
if (_performanceThrottlingRatio < 0) {
|
||||||
_performanceThrottlingRatio = 0;
|
_performanceThrottlingRatio = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Mixer is recovering, sleeping" << _trailingSleepRatio * 100 << "% of frame time. Old cutoff was"
|
qDebug() << "Mixer is recovering, sleeping" << _trailingSleepRatio * 100 << "% of frame time. Old cutoff was"
|
||||||
<< lastCutoffRatio << "and is now" << _performanceThrottlingRatio;
|
<< lastCutoffRatio << "and is now" << _performanceThrottlingRatio;
|
||||||
hasRatioChanged = true;
|
hasRatioChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasRatioChanged) {
|
if (hasRatioChanged) {
|
||||||
// set out min audability threshold from the new ratio
|
// set out min audability threshold from the new ratio
|
||||||
_minAudibilityThreshold = LOUDNESS_TO_DISTANCE_RATIO / (2.0f * (1.0f - _performanceThrottlingRatio));
|
_minAudibilityThreshold = LOUDNESS_TO_DISTANCE_RATIO / (2.0f * (1.0f - _performanceThrottlingRatio));
|
||||||
qDebug() << "Minimum audability required to be mixed is now" << _minAudibilityThreshold;
|
qDebug() << "Minimum audability required to be mixed is now" << _minAudibilityThreshold;
|
||||||
|
|
||||||
framesSinceCutoffEvent = 0;
|
framesSinceCutoffEvent = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasRatioChanged) {
|
if (!hasRatioChanged) {
|
||||||
++framesSinceCutoffEvent;
|
++framesSinceCutoffEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
if (now - _lastPerSecondCallbackTime > USECS_PER_SECOND) {
|
if (now - _lastPerSecondCallbackTime > USECS_PER_SECOND) {
|
||||||
perSecondActions();
|
perSecondActions();
|
||||||
_lastPerSecondCallbackTime = now;
|
_lastPerSecondCallbackTime = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeList->eachNode([&](const SharedNodePointer& node) {
|
nodeList->eachNode([&](const SharedNodePointer& node) {
|
||||||
|
|
||||||
if (node->getLinkedData()) {
|
if (node->getLinkedData()) {
|
||||||
AudioMixerClientData* nodeData = (AudioMixerClientData*)node->getLinkedData();
|
AudioMixerClientData* nodeData = (AudioMixerClientData*)node->getLinkedData();
|
||||||
|
|
||||||
// this function will attempt to pop a frame from each audio stream.
|
// this function will attempt to pop a frame from each audio stream.
|
||||||
// a pointer to the popped data is stored as a member in InboundAudioStream.
|
// a pointer to the popped data is stored as a member in InboundAudioStream.
|
||||||
// That's how the popped audio data will be read for mixing (but only if the pop was successful)
|
// That's how the popped audio data will be read for mixing (but only if the pop was successful)
|
||||||
nodeData->checkBuffersBeforeFrameSend();
|
nodeData->checkBuffersBeforeFrameSend();
|
||||||
|
|
||||||
// if the stream should be muted, send mute packet
|
// if the stream should be muted, send mute packet
|
||||||
if (nodeData->getAvatarAudioStream()
|
if (nodeData->getAvatarAudioStream()
|
||||||
&& shouldMute(nodeData->getAvatarAudioStream()->getQuietestFrameLoudness())) {
|
&& shouldMute(nodeData->getAvatarAudioStream()->getQuietestFrameLoudness())) {
|
||||||
auto mutePacket = NLPacket::create(PacketType::NoisyMute, 0);
|
auto mutePacket = NLPacket::create(PacketType::NoisyMute, 0);
|
||||||
nodeList->sendPacket(std::move(mutePacket), *node);
|
nodeList->sendPacket(std::move(mutePacket), *node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->getType() == NodeType::Agent && node->getActiveSocket()
|
if (node->getType() == NodeType::Agent && node->getActiveSocket()
|
||||||
&& nodeData->getAvatarAudioStream()) {
|
&& nodeData->getAvatarAudioStream()) {
|
||||||
|
|
||||||
int streamsMixed = prepareMixForListeningNode(node.data());
|
int streamsMixed = prepareMixForListeningNode(node.data());
|
||||||
|
|
||||||
std::unique_ptr<NLPacket> mixPacket;
|
std::unique_ptr<NLPacket> mixPacket;
|
||||||
|
|
||||||
if (streamsMixed > 0) {
|
if (streamsMixed > 0) {
|
||||||
int mixPacketBytes = sizeof(quint16) + AudioConstants::NETWORK_FRAME_BYTES_STEREO;
|
int mixPacketBytes = sizeof(quint16) + AudioConstants::NETWORK_FRAME_BYTES_STEREO;
|
||||||
mixPacket = NLPacket::create(PacketType::MixedAudio, mixPacketBytes);
|
mixPacket = NLPacket::create(PacketType::MixedAudio, mixPacketBytes);
|
||||||
|
|
||||||
// pack sequence number
|
// pack sequence number
|
||||||
quint16 sequence = nodeData->getOutgoingSequenceNumber();
|
quint16 sequence = nodeData->getOutgoingSequenceNumber();
|
||||||
mixPacket->writePrimitive(sequence);
|
mixPacket->writePrimitive(sequence);
|
||||||
|
|
||||||
// pack mixed audio samples
|
// pack mixed audio samples
|
||||||
mixPacket->write(reinterpret_cast<char*>(_mixSamples),
|
mixPacket->write(reinterpret_cast<char*>(_mixSamples),
|
||||||
AudioConstants::NETWORK_FRAME_BYTES_STEREO);
|
AudioConstants::NETWORK_FRAME_BYTES_STEREO);
|
||||||
} else {
|
} else {
|
||||||
int silentPacketBytes = sizeof(quint16) + sizeof(quint16);
|
int silentPacketBytes = sizeof(quint16) + sizeof(quint16);
|
||||||
mixPacket = NLPacket::create(PacketType::SilentAudioFrame, silentPacketBytes);
|
mixPacket = NLPacket::create(PacketType::SilentAudioFrame, silentPacketBytes);
|
||||||
|
|
||||||
// pack sequence number
|
// pack sequence number
|
||||||
quint16 sequence = nodeData->getOutgoingSequenceNumber();
|
quint16 sequence = nodeData->getOutgoingSequenceNumber();
|
||||||
mixPacket->writePrimitive(sequence);
|
mixPacket->writePrimitive(sequence);
|
||||||
|
|
||||||
// pack number of silent audio samples
|
// pack number of silent audio samples
|
||||||
quint16 numSilentSamples = AudioConstants::NETWORK_FRAME_SAMPLES_STEREO;
|
quint16 numSilentSamples = AudioConstants::NETWORK_FRAME_SAMPLES_STEREO;
|
||||||
mixPacket->writePrimitive(numSilentSamples);
|
mixPacket->writePrimitive(numSilentSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send audio environment
|
// Send audio environment
|
||||||
sendAudioEnvironmentPacket(node);
|
sendAudioEnvironmentPacket(node);
|
||||||
|
|
||||||
// send mixed audio packet
|
// send mixed audio packet
|
||||||
nodeList->sendPacket(std::move(mixPacket), *node);
|
nodeList->sendPacket(std::move(mixPacket), *node);
|
||||||
nodeData->incrementOutgoingMixedAudioSequenceNumber();
|
nodeData->incrementOutgoingMixedAudioSequenceNumber();
|
||||||
|
|
||||||
// send an audio stream stats packet if it's time
|
// send an audio stream stats packet if it's time
|
||||||
if (_sendAudioStreamStats) {
|
if (_sendAudioStreamStats) {
|
||||||
nodeData->sendAudioStreamStatsPackets(node);
|
nodeData->sendAudioStreamStatsPackets(node);
|
||||||
_sendAudioStreamStats = false;
|
_sendAudioStreamStats = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
++_sumListeners;
|
++_sumListeners;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
++_numStatFrames;
|
++_numStatFrames;
|
||||||
|
|
||||||
// since we're a while loop we need to help Qt's event processing
|
// since we're a while loop we need to help Qt's event processing
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
if (_isFinished) {
|
if (_isFinished) {
|
||||||
// at this point the audio-mixer is done
|
// at this point the audio-mixer is done
|
||||||
// check if we have a deferred delete event to process (which we should once finished)
|
// check if we have a deferred delete event to process (which we should once finished)
|
||||||
QCoreApplication::sendPostedEvents(this, QEvent::DeferredDelete);
|
QCoreApplication::sendPostedEvents(this, QEvent::DeferredDelete);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
usecToSleep = (++nextFrame * AudioConstants::NETWORK_FRAME_USECS) - timer.nsecsElapsed() / 1000; // ns to us
|
usecToSleep = (++nextFrame * AudioConstants::NETWORK_FRAME_USECS) - timer.nsecsElapsed() / 1000; // ns to us
|
||||||
|
|
||||||
if (usecToSleep > 0) {
|
if (usecToSleep > 0) {
|
||||||
usleep(usecToSleep);
|
usleep(usecToSleep);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,13 @@ public slots:
|
||||||
static const InboundAudioStream::Settings& getStreamSettings() { return _streamSettings; }
|
static const InboundAudioStream::Settings& getStreamSettings() { return _streamSettings; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void broadcastMixes();
|
||||||
void handleNodeAudioPacket(QSharedPointer<NLPacket> packet, SharedNodePointer sendingNode);
|
void handleNodeAudioPacket(QSharedPointer<NLPacket> packet, SharedNodePointer sendingNode);
|
||||||
void handleMuteEnvironmentPacket(QSharedPointer<NLPacket> packet, SharedNodePointer sendingNode);
|
void handleMuteEnvironmentPacket(QSharedPointer<NLPacket> packet, SharedNodePointer sendingNode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void domainSettingsRequestComplete();
|
||||||
|
|
||||||
/// adds one stream to the mix for a listening node
|
/// adds one stream to the mix for a listening node
|
||||||
int addStreamToMixForListeningNodeWithStream(AudioMixerClientData* listenerNodeData,
|
int addStreamToMixForListeningNodeWithStream(AudioMixerClientData* listenerNodeData,
|
||||||
const QUuid& streamUUID,
|
const QUuid& streamUUID,
|
||||||
|
|
|
@ -71,7 +71,6 @@ const float BILLBOARD_AND_IDENTITY_SEND_PROBABILITY = 1.0f / 187.0f;
|
||||||
// 1) use the view frustum to cull those avatars that are out of view. Since avatar data doesn't need to be present
|
// 1) use the view frustum to cull those avatars that are out of view. Since avatar data doesn't need to be present
|
||||||
// if the avatar is not in view or in the keyhole.
|
// if the avatar is not in view or in the keyhole.
|
||||||
void AvatarMixer::broadcastAvatarData() {
|
void AvatarMixer::broadcastAvatarData() {
|
||||||
|
|
||||||
int idleTime = QDateTime::currentMSecsSinceEpoch() - _lastFrameTimestamp;
|
int idleTime = QDateTime::currentMSecsSinceEpoch() - _lastFrameTimestamp;
|
||||||
|
|
||||||
++_numStatFrames;
|
++_numStatFrames;
|
||||||
|
@ -513,15 +512,15 @@ void AvatarMixer::sendStatsPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarMixer::run() {
|
void AvatarMixer::run() {
|
||||||
|
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);
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
|
||||||
nodeList->addNodeTypeToInterestSet(NodeType::Agent);
|
|
||||||
|
|
||||||
nodeList->linkedDataCreateCallback = [] (Node* node) {
|
|
||||||
node->setLinkedData(new AvatarMixerClientData());
|
|
||||||
};
|
|
||||||
|
|
||||||
// setup the timer that will be fired on the broadcast thread
|
// setup the timer that will be fired on the broadcast thread
|
||||||
_broadcastTimer = new QTimer;
|
_broadcastTimer = new QTimer;
|
||||||
_broadcastTimer->setInterval(AVATAR_DATA_SEND_INTERVAL_MSECS);
|
_broadcastTimer->setInterval(AVATAR_DATA_SEND_INTERVAL_MSECS);
|
||||||
|
@ -530,33 +529,24 @@ 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
|
void AvatarMixer::domainSettingsRequestComplete() {
|
||||||
DomainHandler& domainHandler = nodeList->getDomainHandler();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
nodeList->addNodeTypeToInterestSet(NodeType::Agent);
|
||||||
qDebug() << "Waiting for domain settings from domain-server.";
|
|
||||||
|
nodeList->linkedDataCreateCallback = [] (Node* node) {
|
||||||
// block until we get the settingsRequestComplete signal
|
node->setLinkedData(new AvatarMixerClientData());
|
||||||
|
};
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse the settings to pull out the values we need
|
// parse the settings to pull out the values we need
|
||||||
parseDomainServerSettings(domainHandler.getSettingsObject());
|
parseDomainServerSettings(nodeList->getDomainHandler().getSettingsObject());
|
||||||
|
|
||||||
// start the broadcastThread
|
// start the broadcastThread
|
||||||
_broadcastThread.start();
|
_broadcastThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AvatarMixer::parseDomainServerSettings(const QJsonObject& domainSettings) {
|
void AvatarMixer::parseDomainServerSettings(const QJsonObject& domainSettings) {
|
||||||
const QString AVATAR_MIXER_SETTINGS_KEY = "avatar_mixer";
|
const QString AVATAR_MIXER_SETTINGS_KEY = "avatar_mixer";
|
||||||
const QString NODE_SEND_BANDWIDTH_KEY = "max_node_send_bandwidth";
|
const QString NODE_SEND_BANDWIDTH_KEY = "max_node_send_bandwidth";
|
||||||
|
|
|
@ -36,6 +36,7 @@ private slots:
|
||||||
void handleAvatarIdentityPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
void handleAvatarIdentityPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
||||||
void handleAvatarBillboardPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
void handleAvatarBillboardPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
||||||
void handleKillAvatarPacket(QSharedPointer<NLPacket> packet);
|
void handleKillAvatarPacket(QSharedPointer<NLPacket> packet);
|
||||||
|
void domainSettingsRequestComplete();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void broadcastAvatarData();
|
void broadcastAvatarData();
|
||||||
|
|
|
@ -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));
|
||||||
|
@ -265,6 +265,4 @@ bool EntityServer::readAdditionalConfiguration(const QJsonObject& settingsSectio
|
||||||
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
||||||
tree->setWantEditLogging(wantEditLogging);
|
tree->setWantEditLogging(wantEditLogging);
|
||||||
tree->setWantTerseEditLogging(wantTerseEditLogging);
|
tree->setWantTerseEditLogging(wantTerseEditLogging);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -951,31 +951,14 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QJsonObject& settingsObject = DependencyManager::get<NodeList>()->getDomainHandler().getSettingsObject();
|
||||||
|
|
||||||
// wait until we have the domain-server settings, otherwise we bail
|
|
||||||
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.";
|
|
||||||
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
|
||||||
|
@ -1084,79 +1067,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());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OctreeServer::domainSettingsRequestComplete() {
|
||||||
|
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
// read the configuration from either the payload or the domain server configuration
|
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
||||||
if (!readConfiguration()) {
|
packetReceiver.registerListener(getMyQueryMessageType(), this, "handleOctreeQueryPacket");
|
||||||
qDebug() << "OctreeServer bailing on run since readConfiguration has failed.";
|
packetReceiver.registerListener(PacketType::OctreeDataNack, this, "handleOctreeDataNackPacket");
|
||||||
setFinished(true);
|
packetReceiver.registerListener(PacketType::JurisdictionRequest, this, "handleJurisdictionRequestPacket");
|
||||||
return; // bailing on run, because readConfiguration failed
|
|
||||||
}
|
readConfiguration();
|
||||||
|
|
||||||
beforeRun(); // after payload has been processed
|
beforeRun(); // after payload has been processed
|
||||||
|
|
||||||
connect(nodeList.data(), SIGNAL(nodeAdded(SharedNodePointer)), SLOT(nodeAdded(SharedNodePointer)));
|
connect(nodeList.data(), SIGNAL(nodeAdded(SharedNodePointer)), SLOT(nodeAdded(SharedNodePointer)));
|
||||||
connect(nodeList.data(), SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(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;
|
||||||
|
@ -1168,6 +1151,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,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);
|
||||||
|
@ -138,8 +139,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();
|
||||||
|
|
|
@ -38,12 +38,17 @@ DomainHandler::DomainHandler(QObject* parent) :
|
||||||
_icePeer(this),
|
_icePeer(this),
|
||||||
_isConnected(false),
|
_isConnected(false),
|
||||||
_settingsObject(),
|
_settingsObject(),
|
||||||
_failedSettingsRequests(0)
|
_settingsTimer(this)
|
||||||
{
|
{
|
||||||
_sockAddr.setObjectName("DomainServer");
|
_sockAddr.setObjectName("DomainServer");
|
||||||
|
|
||||||
// if we get a socket that make sure our NetworkPeer ping timer stops
|
// if we get a socket that make sure our NetworkPeer ping timer stops
|
||||||
connect(this, &DomainHandler::completedSocketDiscovery, &_icePeer, &NetworkPeer::stopPingTimer);
|
connect(this, &DomainHandler::completedSocketDiscovery, &_icePeer, &NetworkPeer::stopPingTimer);
|
||||||
|
|
||||||
|
// setup a timeout for failure on settings requests
|
||||||
|
static const int DOMAIN_SETTINGS_TIMEOUT_MS = 5000;
|
||||||
|
_settingsTimer.setInterval(DOMAIN_SETTINGS_TIMEOUT_MS);
|
||||||
|
connect(&_settingsTimer, &QTimer::timeout, this, &DomainHandler::settingsReceiveFail);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::disconnect() {
|
void DomainHandler::disconnect() {
|
||||||
|
@ -80,13 +85,16 @@ void DomainHandler::sendDisconnectPacket() {
|
||||||
|
|
||||||
void DomainHandler::clearSettings() {
|
void DomainHandler::clearSettings() {
|
||||||
_settingsObject = QJsonObject();
|
_settingsObject = QJsonObject();
|
||||||
_failedSettingsRequests = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::softReset() {
|
void DomainHandler::softReset() {
|
||||||
qCDebug(networking) << "Resetting current domain connection information.";
|
qCDebug(networking) << "Resetting current domain connection information.";
|
||||||
disconnect();
|
disconnect();
|
||||||
|
|
||||||
clearSettings();
|
clearSettings();
|
||||||
|
|
||||||
|
// cancel the failure timeout for any pending requests for settings
|
||||||
|
QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::AutoConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::hardReset() {
|
void DomainHandler::hardReset() {
|
||||||
|
@ -250,34 +258,35 @@ void DomainHandler::requestDomainSettings() {
|
||||||
|
|
||||||
NodeType_t owningNodeType = DependencyManager::get<NodeList>()->getOwnerType();
|
NodeType_t owningNodeType = DependencyManager::get<NodeList>()->getOwnerType();
|
||||||
if (owningNodeType == NodeType::Agent) {
|
if (owningNodeType == NodeType::Agent) {
|
||||||
// for now the agent nodes don't need any settings - this allows local assignment-clients
|
// for now the agent nodes don't need any domain settings
|
||||||
// to connect to a domain that is using automatic networking (since we don't have TCP hole punch yet)
|
|
||||||
_settingsObject = QJsonObject();
|
_settingsObject = QJsonObject();
|
||||||
emit settingsReceived(_settingsObject);
|
emit settingsReceived(_settingsObject);
|
||||||
} else {
|
} else {
|
||||||
if (_settingsObject.isEmpty()) {
|
qCDebug(networking) << "Requesting settings from domain server";
|
||||||
qCDebug(networking) << "Requesting settings from domain server";
|
|
||||||
|
Assignment::Type assignmentType = Assignment::typeForNodeType(DependencyManager::get<NodeList>()->getOwnerType());
|
||||||
Assignment::Type assignmentType = Assignment::typeForNodeType(DependencyManager::get<NodeList>()->getOwnerType());
|
|
||||||
|
auto packet = NLPacket::create(PacketType::DomainSettingsRequest, sizeof(assignmentType), true, false);
|
||||||
auto packet = NLPacket::create(PacketType::DomainSettingsRequest, sizeof(assignmentType), true, false);
|
packet->writePrimitive(assignmentType);
|
||||||
packet->writePrimitive(assignmentType);
|
|
||||||
|
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
nodeList->sendPacket(std::move(packet), _sockAddr);
|
||||||
nodeList->sendPacket(std::move(packet), _sockAddr);
|
|
||||||
}
|
_settingsTimer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::processSettingsPacketList(QSharedPointer<NLPacketList> packetList) {
|
void DomainHandler::processSettingsPacketList(QSharedPointer<NLPacketList> packetList) {
|
||||||
|
// stop our settings timer since we successfully requested the settings we need
|
||||||
|
_settingsTimer.stop();
|
||||||
|
|
||||||
auto data = packetList->getMessage();
|
auto data = packetList->getMessage();
|
||||||
|
|
||||||
_settingsObject = QJsonDocument::fromJson(data).object();
|
_settingsObject = QJsonDocument::fromJson(data).object();
|
||||||
|
|
||||||
qCDebug(networking) << "Received domain settings: \n" << QString(data);
|
if (!_settingsObject.isEmpty()) {
|
||||||
|
qCDebug(networking) << "Received domain settings: \n" << _settingsObject;
|
||||||
// reset failed settings requests to 0, we got them
|
}
|
||||||
_failedSettingsRequests = 0;
|
|
||||||
|
|
||||||
emit settingsReceived(_settingsObject);
|
emit settingsReceived(_settingsObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,8 +127,8 @@ private:
|
||||||
NetworkPeer _icePeer;
|
NetworkPeer _icePeer;
|
||||||
bool _isConnected;
|
bool _isConnected;
|
||||||
QJsonObject _settingsObject;
|
QJsonObject _settingsObject;
|
||||||
int _failedSettingsRequests;
|
|
||||||
QString _pendingPath;
|
QString _pendingPath;
|
||||||
|
QTimer _settingsTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_DomainHandler_h
|
#endif // hifi_DomainHandler_h
|
||||||
|
|
|
@ -77,6 +77,9 @@ void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeTy
|
||||||
connect(_domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
|
connect(_domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
|
||||||
_domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
|
_domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
|
||||||
|
|
||||||
|
// send a domain-server check in immediately
|
||||||
|
checkInWithDomainServerOrExit();
|
||||||
|
|
||||||
// move the domain server time to the NL so check-ins fire from there
|
// move the domain server time to the NL so check-ins fire from there
|
||||||
_domainServerTimer->moveToThread(nodeList->thread());
|
_domainServerTimer->moveToThread(nodeList->thread());
|
||||||
|
|
||||||
|
@ -130,3 +133,8 @@ void ThreadedAssignment::checkInWithDomainServerOrExit() {
|
||||||
DependencyManager::get<NodeList>()->sendDomainServerCheckIn();
|
DependencyManager::get<NodeList>()->sendDomainServerCheckIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThreadedAssignment::domainSettingsRequestFailed() {
|
||||||
|
qDebug() << "Failed to retreive settings object from domain-server. Bailing on assignment.";
|
||||||
|
setFinished(true);
|
||||||
|
}
|
||||||
|
|
|
@ -40,7 +40,10 @@ protected:
|
||||||
bool _isFinished;
|
bool _isFinished;
|
||||||
QTimer* _domainServerTimer = nullptr;
|
QTimer* _domainServerTimer = nullptr;
|
||||||
QTimer* _statsTimer = nullptr;
|
QTimer* _statsTimer = nullptr;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void domainSettingsRequestFailed();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void startSendingStats();
|
void startSendingStats();
|
||||||
void stopSendingStats();
|
void stopSendingStats();
|
||||||
|
|
|
@ -395,7 +395,7 @@ bool SendQueue::isInactive(bool sentAPacket) {
|
||||||
|
|
||||||
#ifdef UDT_CONNECTION_DEBUG
|
#ifdef UDT_CONNECTION_DEBUG
|
||||||
qCDebug(networking) << "SendQueue to" << _destination << "reached" << NUM_TIMEOUTS_BEFORE_INACTIVE << "timeouts"
|
qCDebug(networking) << "SendQueue to" << _destination << "reached" << NUM_TIMEOUTS_BEFORE_INACTIVE << "timeouts"
|
||||||
<< "and 5s before receiving any ACK/NAK and is now inactive. Stopping.";
|
<< "and 5s before receiving any ACK/NAK and is now inactive. Stopping.";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
deactivate();
|
deactivate();
|
||||||
|
@ -427,9 +427,9 @@ bool SendQueue::isInactive(bool sentAPacket) {
|
||||||
if (cvStatus == std::cv_status::timeout) {
|
if (cvStatus == std::cv_status::timeout) {
|
||||||
#ifdef UDT_CONNECTION_DEBUG
|
#ifdef UDT_CONNECTION_DEBUG
|
||||||
qCDebug(networking) << "SendQueue to" << _destination << "has been empty for"
|
qCDebug(networking) << "SendQueue to" << _destination << "has been empty for"
|
||||||
<< EMPTY_QUEUES_INACTIVE_TIMEOUT.count()
|
<< EMPTY_QUEUES_INACTIVE_TIMEOUT.count()
|
||||||
<< "seconds and receiver has ACKed all packets."
|
<< "seconds and receiver has ACKed all packets."
|
||||||
<< "The queue is now inactive and will be stopped.";
|
<< "The queue is now inactive and will be stopped.";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Deactivate queue
|
// Deactivate queue
|
||||||
|
|
Loading…
Reference in a new issue