From 60a301a93b6057bb2c54ac04a7c38c38389037b3 Mon Sep 17 00:00:00 2001 From: Dark1-dev Date: Wed, 1 Mar 2023 21:30:57 +0600 Subject: Add files via upload --- src/TcpTasks/SyncClient/syncclient.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/TcpTasks/SyncClient/syncclient.cpp (limited to 'src/TcpTasks/SyncClient/syncclient.cpp') 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, + 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)); +} -- cgit v1.2.3