#ifndef TCPCLIENT_H
#define TCPCLIENT_H
#include <QTcpSocket>
#include <QByteArray>
#include <QObject>
class   TcpClient:public QObject
{
    Q_OBJECT
public:
    TcpClient(QObject * parent = nullptr);
    virtual  ~TcpClient();
    /*
        des: 连接服务端
    */
    bool connectServer(QString ip ,qint16 port);
    /*
        des: 获取数据
    */
    QByteArray GetData();

    bool sendMessage(QByteArray & data);
    /*
        des: 断开连接
    */
    bool   disConnectServer();

signals:
    void SigRectMsg(QByteArray & dataPack);
private slots:

    void  slotReadMessage();
    void  slotTestReadMessage();
    void  slotDisconnected();
    void  slotSendMessage(QByteArray & data);

private:
    QTcpSocket  m_TcpSocket;
    bool  m_isConnected;
    QByteArray m_msgArray;
};
#endif // TCPCLIENT_H
