3
0
Fork 0
mirror of https://thingvellir.net/git/overte synced 2025-03-27 23:52:03 +01:00

Merge pull request from PhilipRosedale/master

Faceshift only notifies log on first fail to connect
This commit is contained in:
ZappoMan 2013-10-20 21:28:30 -07:00
commit b0bfba3043
2 changed files with 12 additions and 5 deletions
interface/src/devices

View file

@ -20,6 +20,7 @@ const quint16 FACESHIFT_PORT = 33433;
Faceshift::Faceshift() :
_tcpEnabled(false),
_tcpRetryCount(0),
_lastTrackingStateReceived(0),
_eyeGazeLeftPitch(0.0f),
_eyeGazeLeftYaw(0.0f),
@ -88,7 +89,9 @@ void Faceshift::setTCPEnabled(bool enabled) {
void Faceshift::connectSocket() {
if (_tcpEnabled) {
qDebug("Faceshift: Connecting...\n");
if (!_tcpRetryCount) {
qDebug("Faceshift: Connecting...\n");
}
_tcpSocket.connectToHost("localhost", FACESHIFT_PORT);
_tracking = false;
@ -105,11 +108,14 @@ void Faceshift::noteConnected() {
}
void Faceshift::noteError(QAbstractSocket::SocketError error) {
qDebug() << "Faceshift: " << _tcpSocket.errorString() << "\n";
// reconnect after a delay
if (!_tcpRetryCount) {
// Only spam log with fail to connect the first time, so that we can keep waiting for server
qDebug() << "Faceshift: " << _tcpSocket.errorString() << "\n";
}
// retry connection after a 2 second delay
if (_tcpEnabled) {
QTimer::singleShot(1000, this, SLOT(connectSocket()));
_tcpRetryCount++;
QTimer::singleShot(2000, this, SLOT(connectSocket()));
}
}

View file

@ -85,6 +85,7 @@ private:
QUdpSocket _udpSocket;
fs::fsBinaryStream _stream;
bool _tcpEnabled;
int _tcpRetryCount;
bool _tracking;
uint64_t _lastTrackingStateReceived;