mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:21:24 +02:00
Log when attempting to connect and on failure. Wait a second before
attempting to reconnect.
This commit is contained in:
parent
734cb83e81
commit
b406dc7311
2 changed files with 21 additions and 1 deletions
|
@ -6,13 +6,16 @@
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "Faceshift.h"
|
#include "Faceshift.h"
|
||||||
|
|
||||||
using namespace fs;
|
using namespace fs;
|
||||||
|
|
||||||
Faceshift::Faceshift() : _enabled(false) {
|
Faceshift::Faceshift() : _enabled(false) {
|
||||||
|
connect(&_socket, SIGNAL(connected()), SLOT(noteConnected()));
|
||||||
|
connect(&_socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(noteError(QAbstractSocket::SocketError)));
|
||||||
connect(&_socket, SIGNAL(readyRead()), SLOT(readFromSocket()));
|
connect(&_socket, SIGNAL(readyRead()), SLOT(readFromSocket()));
|
||||||
connect(&_socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(connectSocket()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Faceshift::setEnabled(bool enabled) {
|
void Faceshift::setEnabled(bool enabled) {
|
||||||
|
@ -26,11 +29,26 @@ void Faceshift::setEnabled(bool enabled) {
|
||||||
|
|
||||||
void Faceshift::connectSocket() {
|
void Faceshift::connectSocket() {
|
||||||
if (_enabled) {
|
if (_enabled) {
|
||||||
|
qDebug("Faceshift: Connecting...\n");
|
||||||
|
|
||||||
const quint16 FACESHIFT_PORT = 33433;
|
const quint16 FACESHIFT_PORT = 33433;
|
||||||
_socket.connectToHost("localhost", FACESHIFT_PORT);
|
_socket.connectToHost("localhost", FACESHIFT_PORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Faceshift::noteConnected() {
|
||||||
|
qDebug("Faceshift: Connected.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Faceshift::noteError(QAbstractSocket::SocketError error) {
|
||||||
|
qDebug() << "Faceshift: " << _socket.errorString() << "\n";
|
||||||
|
|
||||||
|
// reconnect after a delay
|
||||||
|
if (_enabled) {
|
||||||
|
QTimer::singleShot(1000, this, SLOT(connectSocket()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Faceshift::readFromSocket() {
|
void Faceshift::readFromSocket() {
|
||||||
QByteArray buffer = _socket.readAll();
|
QByteArray buffer = _socket.readAll();
|
||||||
_stream.received(buffer.size(), buffer.constData());
|
_stream.received(buffer.size(), buffer.constData());
|
||||||
|
|
|
@ -36,6 +36,8 @@ public slots:
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void connectSocket();
|
void connectSocket();
|
||||||
|
void noteConnected();
|
||||||
|
void noteError(QAbstractSocket::SocketError error);
|
||||||
void readFromSocket();
|
void readFromSocket();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue