diff options
| author | Dark1-dev <shansarkar272@gmail.com> | 2023-03-01 21:30:57 +0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-01 21:30:57 +0600 |
| commit | 60a301a93b6057bb2c54ac04a7c38c38389037b3 (patch) | |
| tree | b09c5f8bc0045828c660654d8ed6744663856202 /src/TcpTasks/SyncClient/syncclient.cpp | |
| parent | c784240d1af68dbd8d0466822b34fd05d6ccdda1 (diff) | |
| download | Masterserver-Qt5-60a301a93b6057bb2c54ac04a7c38c38389037b3.tar.gz Masterserver-Qt5-60a301a93b6057bb2c54ac04a7c38c38389037b3.zip | |
Add files via upload
Diffstat (limited to 'src/TcpTasks/SyncClient/syncclient.cpp')
| -rw-r--r-- | src/TcpTasks/SyncClient/syncclient.cpp | 27 |
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)); +} |
