mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-07 12:12:39 +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";
|
||||
}
|
||||
_socket->writeDatagram(stunRequestPacket, sizeof(stunRequestPacket), _stunSockAddr);
|
||||
_stunResponseTimerCanceled = false;
|
||||
_stunResponseTimer.singleShot(stunResponseTimeoutMilliSeconds, this, [&] {
|
||||
if (_stunResponseTimerCanceled) {
|
||||
return;
|
||||
}
|
||||
if (_verbose) {
|
||||
qDebug() << "timeout waiting for stun-server response";
|
||||
}
|
||||
QCoreApplication::exit(stunFailureExitStatus);
|
||||
});
|
||||
_stunResponseTimer.setSingleShot(true);
|
||||
connect(&_iceResponseTimer, SIGNAL(timeout()), this, SLOT(stunResponseTimeout()));
|
||||
_stunResponseTimer.start(stunResponseTimeoutMilliSeconds);
|
||||
|
||||
setState(waitForStunResponse);
|
||||
} else {
|
||||
|
@ -215,16 +208,9 @@ void ICEClientApp::doSomething() {
|
|||
}
|
||||
|
||||
sendPacketToIceServer(PacketType::ICEServerQuery, _iceServerAddr, _sessionUUID, peerID);
|
||||
_iceResponseTimerCanceled = false;
|
||||
_iceResponseTimer.singleShot(iceResponseTimeoutMilliSeconds, this, [=] {
|
||||
if (_iceResponseTimerCanceled) {
|
||||
return;
|
||||
}
|
||||
if (_verbose) {
|
||||
qDebug() << "timeout waiting for ice-server response";
|
||||
}
|
||||
QCoreApplication::exit(iceFailureExitStatus);
|
||||
});
|
||||
_iceResponseTimer.setSingleShot(true);
|
||||
connect(&_iceResponseTimer, SIGNAL(timeout()), this, SLOT(iceResponseTimeout()));
|
||||
_iceResponseTimer.start(iceResponseTimeoutMilliSeconds);
|
||||
} else if (_state == pause0) {
|
||||
setState(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,
|
||||
const QUuid& clientID, const QUuid& peerID) {
|
||||
std::unique_ptr<NLPacket> icePacket = NLPacket::create(packetType);
|
||||
|
@ -298,7 +298,6 @@ void ICEClientApp::processSTUNResponse(std::unique_ptr<udt::BasePacket> packet)
|
|||
}
|
||||
|
||||
_stunResponseTimer.stop();
|
||||
_stunResponseTimerCanceled = true;
|
||||
|
||||
uint16_t newPublicPort;
|
||||
QHostAddress newPublicAddress;
|
||||
|
@ -331,7 +330,6 @@ void ICEClientApp::processPacket(std::unique_ptr<udt::Packet> packet) {
|
|||
if (nlPacket->getType() == PacketType::ICEServerPeerInformation) {
|
||||
// cancel the timeout timer
|
||||
_iceResponseTimer.stop();
|
||||
_iceResponseTimerCanceled = true;
|
||||
|
||||
QDataStream iceResponseStream(message->getMessage());
|
||||
if (!_domainServerPeerSet) {
|
||||
|
|
|
@ -33,6 +33,10 @@ public:
|
|||
const int stunResponseTimeoutMilliSeconds { 2000 };
|
||||
const int iceResponseTimeoutMilliSeconds { 2000 };
|
||||
|
||||
public slots:
|
||||
void iceResponseTimeout();
|
||||
void stunResponseTimeout();
|
||||
|
||||
private:
|
||||
enum State {
|
||||
lookUpStunServer, // 0
|
||||
|
@ -83,9 +87,7 @@ private:
|
|||
int _state { 0 };
|
||||
|
||||
QTimer _stunResponseTimer;
|
||||
bool _stunResponseTimerCanceled { false };
|
||||
QTimer _iceResponseTimer;
|
||||
bool _iceResponseTimerCanceled { false };
|
||||
int _domainPingCount { 0 };
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue