mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 07:39:44 +02:00
Send ping requests to the nodes (AvatarMixer, AudioMixer, EntityServer) that the Assignment agent connected with to keep the connections alive.
This commit is contained in:
parent
6a5c2982ac
commit
7325e6a7b7
2 changed files with 28 additions and 1 deletions
|
@ -107,6 +107,7 @@ void Agent::handleAudioPacket(QSharedPointer<NLPacket> packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString AGENT_LOGGING_NAME = "agent";
|
const QString AGENT_LOGGING_NAME = "agent";
|
||||||
|
const int PING_INTERVAL = 1000;
|
||||||
|
|
||||||
void Agent::run() {
|
void Agent::run() {
|
||||||
ThreadedAssignment::commonInit(AGENT_LOGGING_NAME, NodeType::Agent);
|
ThreadedAssignment::commonInit(AGENT_LOGGING_NAME, NodeType::Agent);
|
||||||
|
@ -118,6 +119,10 @@ void Agent::run() {
|
||||||
<< NodeType::EntityServer
|
<< NodeType::EntityServer
|
||||||
);
|
);
|
||||||
|
|
||||||
|
_pingTimer = new QTimer(this);
|
||||||
|
connect(_pingTimer, SIGNAL(timeout()), SLOT(sendPingRequests()));
|
||||||
|
_pingTimer->start(PING_INTERVAL);
|
||||||
|
|
||||||
// figure out the URL for the script for this agent assignment
|
// figure out the URL for the script for this agent assignment
|
||||||
QUrl scriptURL;
|
QUrl scriptURL;
|
||||||
if (_payload.isEmpty()) {
|
if (_payload.isEmpty()) {
|
||||||
|
@ -193,7 +198,27 @@ void Agent::run() {
|
||||||
|
|
||||||
void Agent::aboutToFinish() {
|
void Agent::aboutToFinish() {
|
||||||
_scriptEngine.stop();
|
_scriptEngine.stop();
|
||||||
|
|
||||||
|
_pingTimer->stop();
|
||||||
|
delete _pingTimer;
|
||||||
|
|
||||||
// our entity tree is going to go away so tell that to the EntityScriptingInterface
|
// our entity tree is going to go away so tell that to the EntityScriptingInterface
|
||||||
DependencyManager::get<EntityScriptingInterface>()->setEntityTree(NULL);
|
DependencyManager::get<EntityScriptingInterface>()->setEntityTree(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Agent::sendPingRequests() {
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
|
nodeList->eachMatchingNode([](const SharedNodePointer& node)->bool {
|
||||||
|
switch (node->getType()) {
|
||||||
|
case NodeType::AvatarMixer:
|
||||||
|
case NodeType::AudioMixer:
|
||||||
|
case NodeType::EntityServer:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}, [nodeList](const SharedNodePointer& node) {
|
||||||
|
nodeList->sendPacket(nodeList->constructPingPacket(), *node);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -58,11 +58,13 @@ private slots:
|
||||||
void handleAudioPacket(QSharedPointer<NLPacket> packet);
|
void handleAudioPacket(QSharedPointer<NLPacket> packet);
|
||||||
void handleOctreePacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
void handleOctreePacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
||||||
void handleJurisdictionPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
void handleJurisdictionPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode);
|
||||||
|
void sendPingRequests();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScriptEngine _scriptEngine;
|
ScriptEngine _scriptEngine;
|
||||||
EntityEditPacketSender _entityEditSender;
|
EntityEditPacketSender _entityEditSender;
|
||||||
EntityTreeHeadlessViewer _entityViewer;
|
EntityTreeHeadlessViewer _entityViewer;
|
||||||
|
QTimer* _pingTimer;
|
||||||
|
|
||||||
MixedAudioStream _receivedAudioStream;
|
MixedAudioStream _receivedAudioStream;
|
||||||
float _lastReceivedAudioLoudness;
|
float _lastReceivedAudioLoudness;
|
||||||
|
|
Loading…
Reference in a new issue