Properly reconnect to Hyperion server on disconnects.
This commit is contained in:
parent
5441d1aba6
commit
acafd14ec2
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ cmake_install.cmake
|
|||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
Makefile
|
Makefile
|
||||||
Hyperion_Grabber_X11_QT
|
Hyperion_Grabber_X11_QT
|
||||||
|
CMakeLists.txt.user
|
||||||
|
|||||||
@ -11,7 +11,7 @@ hgx11::hgx11(QString addr, QString port, QString scale, QString frameskip, QStri
|
|||||||
_inactiveTime_m = (inactiveTime.toInt() > 0 ? QString::number(inactiveTime.toInt() * 1000) : "0");
|
_inactiveTime_m = (inactiveTime.toInt() > 0 ? QString::number(inactiveTime.toInt() * 1000) : "0");
|
||||||
|
|
||||||
_grabber_p = new hgx11grab(_scale_m.toInt(), _frameskip_m.toUShort());
|
_grabber_p = new hgx11grab(_scale_m.toInt(), _frameskip_m.toUShort());
|
||||||
_hclient_p = new hgx11net(_addr_m.toStdString().c_str(), _port_m.toUShort());
|
_hclient_p = new hgx11net(_addr_m, _port_m.toUShort());
|
||||||
_damage_p = new hgx11damage();
|
_damage_p = new hgx11damage();
|
||||||
|
|
||||||
_hclient_p->imgWidth = QString::number(_grabber_p->getDest_width());
|
_hclient_p->imgWidth = QString::number(_grabber_p->getDest_width());
|
||||||
|
|||||||
21
hgx11net.cpp
21
hgx11net.cpp
@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
// public
|
// public
|
||||||
|
|
||||||
hgx11net::hgx11net(const char *host, ushort port)
|
hgx11net::hgx11net(QString host, ushort port)
|
||||||
{
|
{
|
||||||
_sock_p = new QTcpSocket(this);
|
_sock_p = new QTcpSocket(this);
|
||||||
connect(_sock_p, SIGNAL(disconnected()), this, SLOT(_disconnected()));
|
|
||||||
_host_m = host;
|
_host_m = host;
|
||||||
_port_m = port;
|
_port_m = port;
|
||||||
this->_connectHost();
|
this->_connectHost();
|
||||||
@ -45,7 +44,13 @@ void hgx11net::setLedColor(quint8 R, quint8 G, quint8 B)
|
|||||||
|
|
||||||
bool hgx11net::_isConnected()
|
bool hgx11net::_isConnected()
|
||||||
{
|
{
|
||||||
return (_sock_p->state() == QAbstractSocket::ConnectedState);
|
bool connected = (_sock_p->state() == QAbstractSocket::ConnectedState);
|
||||||
|
if (!connected) {
|
||||||
|
_sock_p->reset();
|
||||||
|
_connectHost();
|
||||||
|
connected = (_sock_p->state() == QAbstractSocket::ConnectedState);
|
||||||
|
}
|
||||||
|
return connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hgx11net::_connectHost()
|
void hgx11net::_connectHost()
|
||||||
@ -74,13 +79,3 @@ void hgx11net::sendImage(QByteArray *imgdata)
|
|||||||
_cmd_m.append(",\"priority\":100}\n");
|
_cmd_m.append(",\"priority\":100}\n");
|
||||||
_sock_p->write(_cmd_m);
|
_sock_p->write(_cmd_m);
|
||||||
}
|
}
|
||||||
|
|
||||||
// private slots
|
|
||||||
|
|
||||||
void hgx11net::_disconnected()
|
|
||||||
{
|
|
||||||
while (!_isConnected()) {
|
|
||||||
_connectHost();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public:
|
|||||||
QString imgWidth;
|
QString imgWidth;
|
||||||
QString imgHeight;
|
QString imgHeight;
|
||||||
|
|
||||||
hgx11net(const char *, ushort);
|
hgx11net(QString, ushort);
|
||||||
~hgx11net();
|
~hgx11net();
|
||||||
|
|
||||||
void clearLeds();
|
void clearLeds();
|
||||||
@ -23,7 +23,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QTcpSocket *_sock_p;
|
QTcpSocket *_sock_p;
|
||||||
QByteArray _cmd_m;
|
QByteArray _cmd_m;
|
||||||
const char *_host_m;
|
QString _host_m;
|
||||||
quint16 _port_m;
|
quint16 _port_m;
|
||||||
|
|
||||||
void _connectHost();
|
void _connectHost();
|
||||||
@ -31,9 +31,6 @@ private:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void sendImage(QByteArray *);
|
void sendImage(QByteArray *);
|
||||||
|
|
||||||
private slots:
|
|
||||||
void _disconnected();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HGX11NET_H
|
#endif // HGX11NET_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user