summaryrefslogtreecommitdiff
path: root/src/client.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.h')
-rw-r--r--src/client.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/client.h b/src/client.h
new file mode 100644
index 0000000..d590a59
--- /dev/null
+++ b/src/client.h
@@ -0,0 +1,38 @@
+// -*- c++ -*-
+#pragma once
+
+#include <QtCore>
+#include <QtNetwork>
+
+class QTcpSocket;
+class QTimer;
+
+class Client
+ : public QObject
+{
+ Q_OBJECT
+public:
+ Client(QObject *parent = 0);
+
+public slots:
+ bool connectToHost(const QString& host);
+ bool writeData(const QByteArray& data);
+ void errorOccurred(QAbstractSocket::SocketError socketError);
+ void connected();
+ void disconnected();
+ void timeout();
+
+signals:
+ void isConnected();
+ void isDisconnected();
+
+private:
+ void retryConnect();
+
+ QTcpSocket *socket;
+ QString host;
+ QTimer *timer;
+ int retries{10};
+ int interval{5};
+ int interval_long{120};
+};