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
|
/// Called when disconnected from XBMC
|
||||||
void disconnected();
|
void disconnected();
|
||||||
|
|
||||||
|
/// reconnect to XBMC
|
||||||
|
void reconnect();
|
||||||
|
|
||||||
/// Called when a connection error was encountered
|
/// Called when a connection error was encountered
|
||||||
void connectionError(QAbstractSocket::SocketError error);
|
void connectionError(QAbstractSocket::SocketError error);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, b
|
|||||||
|
|
||||||
void XBMCVideoChecker::start()
|
void XBMCVideoChecker::start()
|
||||||
{
|
{
|
||||||
disconnected();
|
reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void XBMCVideoChecker::receiveReply()
|
void XBMCVideoChecker::receiveReply()
|
||||||
@ -157,17 +157,42 @@ void XBMCVideoChecker::connected()
|
|||||||
void XBMCVideoChecker::disconnected()
|
void XBMCVideoChecker::disconnected()
|
||||||
{
|
{
|
||||||
std::cout << "XBMC Disconnected" << std::endl;
|
std::cout << "XBMC Disconnected" << std::endl;
|
||||||
|
reconnect();
|
||||||
// try to connect
|
|
||||||
_socket.connectToHost(_address, _port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// try to connect
|
||||||
QTimer::singleShot(1000, this, SLOT(disconnected()));
|
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)
|
void XBMCVideoChecker::setGrabbingMode(GrabbingMode newGrabbingMode)
|
||||||
|
Loading…
Reference in New Issue
Block a user