mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
fixed some XBMC checker reconnection
Former-commit-id: ec9c327965597b4b552d939cfb664ca95e2f1786
This commit is contained in:
parent
efcb8ec179
commit
3d3c8c93b8
@ -1 +1 @@
|
||||
a975349d4d5b010597f15b5efa6363f43434627f
|
||||
27dcc318ae9a9226676fb33626500e57703d7b6d
|
@ -65,6 +65,9 @@ private slots:
|
||||
/// Called when disconnected from XBMC
|
||||
void disconnected();
|
||||
|
||||
/// reconnect to XBMC
|
||||
void reconnect();
|
||||
|
||||
/// Called when a connection error was encountered
|
||||
void connectionError(QAbstractSocket::SocketError error);
|
||||
|
||||
|
@ -44,7 +44,7 @@ XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, b
|
||||
|
||||
void XBMCVideoChecker::start()
|
||||
{
|
||||
disconnected();
|
||||
reconnect();
|
||||
}
|
||||
|
||||
void XBMCVideoChecker::receiveReply()
|
||||
@ -157,17 +157,42 @@ void XBMCVideoChecker::connected()
|
||||
void XBMCVideoChecker::disconnected()
|
||||
{
|
||||
std::cout << "XBMC Disconnected" << std::endl;
|
||||
|
||||
// try to connect
|
||||
_socket.connectToHost(_address, _port);
|
||||
reconnect();
|
||||
}
|
||||
|
||||
void XBMCVideoChecker::connectionError(QAbstractSocket::SocketError)
|
||||
void XBMCVideoChecker::reconnect()
|
||||
{
|
||||
std::cout << "XBMC Connection error" << std::endl;
|
||||
if (_socket.state() == QTcpSocket::ConnectedState)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// try to connect again in 1 second
|
||||
QTimer::singleShot(1000, this, SLOT(disconnected()));
|
||||
// try to connect
|
||||
switch (_socket.state())
|
||||
{
|
||||
case QTcpSocket::ConnectingState:
|
||||
// Somehow when XBMC restarts we get stuck in connecting state
|
||||
// If we get here we tried to connect already for 5 seconds. abort and try again in 1 second.
|
||||
_socket.reset();
|
||||
_socket.waitForDisconnected(50);
|
||||
QTimer::singleShot(1000, this, SLOT(reconnect()));
|
||||
break;
|
||||
case QTcpSocket::UnconnectedState:
|
||||
_socket.connectToHost(_address, _port);
|
||||
QTimer::singleShot(10000, this, SLOT(reconnect()));
|
||||
break;
|
||||
default:
|
||||
QTimer::singleShot(10000, this, SLOT(reconnect()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void XBMCVideoChecker::connectionError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
std::cout << "XBMC Connection error (" << error << ")" << std::endl;
|
||||
|
||||
// close the socket
|
||||
_socket.close();
|
||||
}
|
||||
|
||||
void XBMCVideoChecker::setGrabbingMode(GrabbingMode newGrabbingMode)
|
||||
|
Loading…
Reference in New Issue
Block a user