#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QObject>
#include <QTcpSocket>
#include <QHostAddress>
#include <QDataStream>
#include <QTcpServer>
#include <QFile>
#include <QCoreApplication>
#include "Core\recognizesystem.h"
#include "Core\tools.h"
#include "Core\UpdateController.h"
#include "Core\externalexecuter.h"

class UpdateController;
class RecognizeSystem;
class SendSystem;
class MainWindow;
class ServerSettings;

class TCPClient : public QObject
{
    Q_OBJECT


public:
    explicit TCPClient(QObject *parent = 0);
    void initialize(MainWindow *mainWindow,RecognizeSystem *recognize,ExternalExecuter *externalExecuter,SendSystem *sendSystem);
    void setConnect(ServerSettings *serverSettings);

    void waitRead(int time);
    QTcpSocket* getSocket();
    ~TCPClient();

    bool getIsConnected() const;

signals:
    void sigSendDebugLog(QString message);
    void sigServerDisconnect();
    void sigConnectionState(bool flag);

public slots:
    void slotSendCommand(QString message);
    void slotConnectNotify();

private slots:
    void slotReadyRead();


private:
    SendSystem *sendSystem;
    QTcpSocket *socket;
    RecognizeSystem *recognizeSystem;
    ExternalExecuter * externalExecuter;
    bool isConnected;

    void setDisconnect();
};

#endif // TCPCLIENT_H
