mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 15:09:34 +02:00
Move sendPingPackets
This commit is contained in:
parent
e74df484cc
commit
77a7814854
4 changed files with 34 additions and 39 deletions
|
@ -163,22 +163,6 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum CustomEventTypes {
|
|
||||||
Lambda = QEvent::User + 1
|
|
||||||
};
|
|
||||||
|
|
||||||
class LambdaEvent : public QEvent {
|
|
||||||
std::function<void()> _fun;
|
|
||||||
public:
|
|
||||||
LambdaEvent(const std::function<void()> & fun) :
|
|
||||||
QEvent(static_cast<QEvent::Type>(Lambda)), _fun(fun) {
|
|
||||||
}
|
|
||||||
LambdaEvent(std::function<void()> && fun) :
|
|
||||||
QEvent(static_cast<QEvent::Type>(Lambda)), _fun(fun) {
|
|
||||||
}
|
|
||||||
void call() { _fun(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static QTimer* locationUpdateTimer = NULL;
|
static QTimer* locationUpdateTimer = NULL;
|
||||||
|
@ -239,6 +223,22 @@ public:
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum CustomEventTypes {
|
||||||
|
Lambda = QEvent::User + 1
|
||||||
|
};
|
||||||
|
|
||||||
|
class LambdaEvent : public QEvent {
|
||||||
|
std::function<void()> _fun;
|
||||||
|
public:
|
||||||
|
LambdaEvent(const std::function<void()> & fun) :
|
||||||
|
QEvent(static_cast<QEvent::Type>(Lambda)), _fun(fun) {
|
||||||
|
}
|
||||||
|
LambdaEvent(std::function<void()> && fun) :
|
||||||
|
QEvent(static_cast<QEvent::Type>(Lambda)), _fun(fun) {
|
||||||
|
}
|
||||||
|
void call() { _fun(); }
|
||||||
|
};
|
||||||
|
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||||
QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
|
QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
|
||||||
|
|
||||||
|
@ -2090,29 +2090,10 @@ bool Application::acceptSnapshot(const QString& urlString) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::sendPingPackets() {
|
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
|
||||||
|
|
||||||
nodeList->eachMatchingNode([](const SharedNodePointer& node)->bool {
|
|
||||||
switch (node->getType()) {
|
|
||||||
case NodeType::AvatarMixer:
|
|
||||||
case NodeType::AudioMixer:
|
|
||||||
case NodeType::EntityServer:
|
|
||||||
case NodeType::AssetServer:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}, [nodeList](const SharedNodePointer& node) {
|
|
||||||
nodeList->sendPacket(nodeList->constructPingPacket(), *node);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Every second, check the frame rates and other stuff
|
// Every second, check the frame rates and other stuff
|
||||||
void Application::checkFPS() {
|
void Application::checkFPS() {
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
|
||||||
sendPingPackets();
|
DependencyManager::get<NodeList>()->sendPingPackets();
|
||||||
}
|
}
|
||||||
|
|
||||||
float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f;
|
float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f;
|
||||||
|
@ -3804,7 +3785,6 @@ void Application::clearDomainOctreeDetails() {
|
||||||
|
|
||||||
// reset the model renderer
|
// reset the model renderer
|
||||||
_entities.clear();
|
_entities.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::domainChanged(const QString& domainHostname) {
|
void Application::domainChanged(const QString& domainHostname) {
|
||||||
|
|
|
@ -464,8 +464,6 @@ private slots:
|
||||||
private:
|
private:
|
||||||
void resetCameras(Camera& camera, const glm::uvec2& size);
|
void resetCameras(Camera& camera, const glm::uvec2& size);
|
||||||
|
|
||||||
void sendPingPackets();
|
|
||||||
|
|
||||||
void initDisplay();
|
void initDisplay();
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
|
|
@ -661,6 +661,22 @@ void LimitedNodeList::sendSTUNRequest() {
|
||||||
_nodeSocket.writeDatagram(stunRequestPacket, sizeof(stunRequestPacket), _stunSockAddr);
|
_nodeSocket.writeDatagram(stunRequestPacket, sizeof(stunRequestPacket), _stunSockAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LimitedNodeList::sendPingPackets() {
|
||||||
|
eachMatchingNode([](const SharedNodePointer& node)->bool {
|
||||||
|
switch (node->getType()) {
|
||||||
|
case NodeType::AvatarMixer:
|
||||||
|
case NodeType::AudioMixer:
|
||||||
|
case NodeType::EntityServer:
|
||||||
|
case NodeType::AssetServer:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}, [&](const SharedNodePointer& node) {
|
||||||
|
sendPacket(constructPingPacket(), *node);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void LimitedNodeList::processSTUNResponse(std::unique_ptr<udt::BasePacket> packet) {
|
void LimitedNodeList::processSTUNResponse(std::unique_ptr<udt::BasePacket> packet) {
|
||||||
// check the cookie to make sure this is actually a STUN response
|
// check the cookie to make sure this is actually a STUN response
|
||||||
// and read the first attribute and make sure it is a XOR_MAPPED_ADDRESS
|
// and read the first attribute and make sure it is a XOR_MAPPED_ADDRESS
|
||||||
|
|
|
@ -230,6 +230,7 @@ public slots:
|
||||||
|
|
||||||
void startSTUNPublicSocketUpdate();
|
void startSTUNPublicSocketUpdate();
|
||||||
virtual void sendSTUNRequest();
|
virtual void sendSTUNRequest();
|
||||||
|
void sendPingPackets();
|
||||||
|
|
||||||
void killNodeWithUUID(const QUuid& nodeUUID);
|
void killNodeWithUUID(const QUuid& nodeUUID);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue