Commit a105e73f authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Add support for lost() signal

parent 76a9c42a
......@@ -138,8 +138,10 @@ CanDriver_cobsTcp::CanDriver_cobsTcp (QObject * parent)
{
m_socket = new QTcpSocket (this);
m_server = new QTcpServer (this);
connect (m_socket, &QTcpSocket::readyRead, this, &CanDriver_cobsTcp::onSocketReadyRead);
connect (m_server, &QTcpServer::newConnection, this, &CanDriver_cobsTcp::onClientConnected);
typedef void (QAbstractSocket::*ErrorSignal) (QAbstractSocket::SocketError);
connect (m_socket, &QTcpSocket::readyRead, this, &CanDriver_cobsTcp::onSocketReadyRead);
connect (m_socket, ErrorSignal (&QTcpSocket::error), this, &CanDriver_cobsTcp::onSocketError);
connect (m_server, &QTcpServer::newConnection, this, &CanDriver_cobsTcp::onClientConnected);
}
bool CanDriver_cobsTcp::init (const QVariantMap & options) {
......@@ -304,6 +306,10 @@ void CanDriver_cobsTcp::onClientDisconnected (void) {
}
}
void CanDriver_cobsTcp::onSocketError (void) {
emit lost ();
}
void CanDriver_cobsTcp::onClientSentData (void) {
if (QTcpSocket * client = qobject_cast<QTcpSocket *> (sender ())) {
const QByteArray data = client->readAll ();
......
......@@ -94,6 +94,7 @@ public slots: // CanDriver interface
private slots:
void onSocketReadyRead (void);
void onSocketError (void);
void onClientConnected (void);
void onClientSentData (void);
void onClientDisconnected (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment