mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 14:30:08 +02:00
fix timer use
This commit is contained in:
parent
785d67b87a
commit
0510411ac1
2 changed files with 24 additions and 24 deletions
|
@ -178,16 +178,9 @@ void ICEClientApp::doSomething() {
|
||||||
qDebug() << "sending STUN request";
|
qDebug() << "sending STUN request";
|
||||||
}
|
}
|
||||||
_socket->writeDatagram(stunRequestPacket, sizeof(stunRequestPacket), _stunSockAddr);
|
_socket->writeDatagram(stunRequestPacket, sizeof(stunRequestPacket), _stunSockAddr);
|
||||||
_stunResponseTimerCanceled = false;
|
_stunResponseTimer.setSingleShot(true);
|
||||||
_stunResponseTimer.singleShot(stunResponseTimeoutMilliSeconds, this, [&] {
|
connect(&_iceResponseTimer, SIGNAL(timeout()), this, SLOT(stunResponseTimeout()));
|
||||||
if (_stunResponseTimerCanceled) {
|
_stunResponseTimer.start(stunResponseTimeoutMilliSeconds);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_verbose) {
|
|
||||||
qDebug() << "timeout waiting for stun-server response";
|
|
||||||
}
|
|
||||||
QCoreApplication::exit(stunFailureExitStatus);
|
|
||||||
});
|
|
||||||
|
|
||||||
setState(waitForStunResponse);
|
setState(waitForStunResponse);
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,16 +208,9 @@ void ICEClientApp::doSomething() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sendPacketToIceServer(PacketType::ICEServerQuery, _iceServerAddr, _sessionUUID, peerID);
|
sendPacketToIceServer(PacketType::ICEServerQuery, _iceServerAddr, _sessionUUID, peerID);
|
||||||
_iceResponseTimerCanceled = false;
|
_iceResponseTimer.setSingleShot(true);
|
||||||
_iceResponseTimer.singleShot(iceResponseTimeoutMilliSeconds, this, [=] {
|
connect(&_iceResponseTimer, SIGNAL(timeout()), this, SLOT(iceResponseTimeout()));
|
||||||
if (_iceResponseTimerCanceled) {
|
_iceResponseTimer.start(iceResponseTimeoutMilliSeconds);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_verbose) {
|
|
||||||
qDebug() << "timeout waiting for ice-server response";
|
|
||||||
}
|
|
||||||
QCoreApplication::exit(iceFailureExitStatus);
|
|
||||||
});
|
|
||||||
} else if (_state == pause0) {
|
} else if (_state == pause0) {
|
||||||
setState(pause1);
|
setState(pause1);
|
||||||
} else if (_state == pause1) {
|
} else if (_state == pause1) {
|
||||||
|
@ -237,6 +223,20 @@ void ICEClientApp::doSomething() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ICEClientApp::iceResponseTimeout() {
|
||||||
|
if (_verbose) {
|
||||||
|
qDebug() << "timeout waiting for ice-server response";
|
||||||
|
}
|
||||||
|
QCoreApplication::exit(iceFailureExitStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICEClientApp::stunResponseTimeout() {
|
||||||
|
if (_verbose) {
|
||||||
|
qDebug() << "timeout waiting for stun-server response";
|
||||||
|
}
|
||||||
|
QCoreApplication::exit(stunFailureExitStatus);
|
||||||
|
}
|
||||||
|
|
||||||
void ICEClientApp::sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr,
|
void ICEClientApp::sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr,
|
||||||
const QUuid& clientID, const QUuid& peerID) {
|
const QUuid& clientID, const QUuid& peerID) {
|
||||||
std::unique_ptr<NLPacket> icePacket = NLPacket::create(packetType);
|
std::unique_ptr<NLPacket> icePacket = NLPacket::create(packetType);
|
||||||
|
@ -298,7 +298,6 @@ void ICEClientApp::processSTUNResponse(std::unique_ptr<udt::BasePacket> packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
_stunResponseTimer.stop();
|
_stunResponseTimer.stop();
|
||||||
_stunResponseTimerCanceled = true;
|
|
||||||
|
|
||||||
uint16_t newPublicPort;
|
uint16_t newPublicPort;
|
||||||
QHostAddress newPublicAddress;
|
QHostAddress newPublicAddress;
|
||||||
|
@ -331,7 +330,6 @@ void ICEClientApp::processPacket(std::unique_ptr<udt::Packet> packet) {
|
||||||
if (nlPacket->getType() == PacketType::ICEServerPeerInformation) {
|
if (nlPacket->getType() == PacketType::ICEServerPeerInformation) {
|
||||||
// cancel the timeout timer
|
// cancel the timeout timer
|
||||||
_iceResponseTimer.stop();
|
_iceResponseTimer.stop();
|
||||||
_iceResponseTimerCanceled = true;
|
|
||||||
|
|
||||||
QDataStream iceResponseStream(message->getMessage());
|
QDataStream iceResponseStream(message->getMessage());
|
||||||
if (!_domainServerPeerSet) {
|
if (!_domainServerPeerSet) {
|
||||||
|
|
|
@ -33,6 +33,10 @@ public:
|
||||||
const int stunResponseTimeoutMilliSeconds { 2000 };
|
const int stunResponseTimeoutMilliSeconds { 2000 };
|
||||||
const int iceResponseTimeoutMilliSeconds { 2000 };
|
const int iceResponseTimeoutMilliSeconds { 2000 };
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void iceResponseTimeout();
|
||||||
|
void stunResponseTimeout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum State {
|
enum State {
|
||||||
lookUpStunServer, // 0
|
lookUpStunServer, // 0
|
||||||
|
@ -83,9 +87,7 @@ private:
|
||||||
int _state { 0 };
|
int _state { 0 };
|
||||||
|
|
||||||
QTimer _stunResponseTimer;
|
QTimer _stunResponseTimer;
|
||||||
bool _stunResponseTimerCanceled { false };
|
|
||||||
QTimer _iceResponseTimer;
|
QTimer _iceResponseTimer;
|
||||||
bool _iceResponseTimerCanceled { false };
|
|
||||||
int _domainPingCount { 0 };
|
int _domainPingCount { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue