aboutsummaryrefslogtreecommitdiff
path: root/src/TcpTasks/ListenClientHandler/listenclienthandler.h
blob: 425931200ca3c215a536204b696c6aeef48da861 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef LISTENCLIENTHANDLER_H
#define LISTENCLIENTHANDLER_H

#include <QTimer>
#include <QTcpSocket>
#include <QHostAddress>

#include "Core/CoreObject/coreobject.h"
#include "Database/Common/commonactions.h"

#include "Protocols/GameSpy0/gamespy0.h"
#include "Protocols/enctype2.h"
#include "Protocols/GameSpy0/securevalidate.h"

class ListenClientHandler : public QObject
{
    Q_OBJECT
public:
    ListenClientHandler(const QSharedPointer<CoreObject> &coreObject,
                        QTcpSocket *tcpSocket);

private:
    const int _timeOutTime_ms = 15000;

    QSharedPointer<CoreObject> _coreObject;
    QScopedPointer<QTcpSocket>  _tcpSocket;
    QTimer                      _timeOut;
    QString                     _rxBuffer = "";
    bool                        _hasValidated = false;
    bool                        _requestEnctype2 = false;

    QString _clientLabel;
    QString _secure;
private:
    void disconnect();

    // database functions
    QByteArray compileServerlist (const QString &gamename,
                                  const int     &serverAge_s,
                                  const bool    &cmp);
    QByteArray compileSyncList(const QStringList &gamenameList,
                               const int         &serverAge_s);

private slots:
    void onListenClientRead();
    void onListenClientTimeOut();
    void onListenClientDisconnect();

};

#endif // LISTENCLIENTHANDLER_H