aboutsummaryrefslogtreecommitdiff
path: root/src/TcpTasks/SyncClient/syncclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/TcpTasks/SyncClient/syncclient.cpp')
-rw-r--r--src/TcpTasks/SyncClient/syncclient.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/TcpTasks/SyncClient/syncclient.cpp b/src/TcpTasks/SyncClient/syncclient.cpp
new file mode 100644
index 0000000..a5a1531
--- /dev/null
+++ b/src/TcpTasks/SyncClient/syncclient.cpp
@@ -0,0 +1,27 @@
+#include "syncclient.h"
+
+SyncClient::SyncClient(const QSharedPointer<CoreObject> &coreObject,
+ const QString &remoteHost,
+ const unsigned short int &remotePort)
+{
+ // create local access
+ this->_coreObject = coreObject;
+
+ // connect events and functions
+ connect(&_tcpSocket, &QTcpSocket::connected, this, &SyncClient::onSyncConnect);
+ connect(&_tcpSocket, &QTcpSocket::readyRead, this, &SyncClient::onSyncRead);
+ connect(&_tcpSocket, &QTcpSocket::disconnected, this, &SyncClient::onSyncDisconnect);
+ connect(&_timeOut, &QTimer::timeout, this, &SyncClient::onSyncTimeOut);
+
+ // convenience label to found
+ _clientLabel = QStringLiteral("%1:%2")
+ .arg(remoteHost, QString::number(remotePort));
+
+ // set timeout
+ _timeOut.setInterval( _timeOutTime_ms );
+ _timeOut.start(); // connection timout time === read timeout time
+
+ // connect to remote masterserver
+ _tcpSocket.connectToHost(remoteHost, remotePort);
+ _coreObject->Log.logEvent("tcp", QStringLiteral("connecting to %1").arg(_clientLabel));
+}