1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/qqtclient.h
2017-08-13 18:27:13 +08:00

76 lines
1.9 KiB
C++
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**************************************************
* QQTClient
* 在一个工程当中仅仅存在一个实例通过调用QQTClient实现。
**************************************************/
#ifndef QQT_CLIENT_H
#define QQT_CLIENT_H
#include <QTcpSocket>
#include "qqtprotocol.h"
#include "QStringList"
#define TANK_Q_TCP_SOCKET 0
#define TANK_Q_SOCKET 1
#define TANK_Q_THREAD 0
#define _TCP_BLOCKDATA_SIZE 0x400
#define _TCP_RECVBUFF_SIZE 0x800
/**
* @brief 客户端决定和协议的交互关系;只跟协议打交道;
*/
class QQTClient : public QTcpSocket
{
Q_OBJECT
public:
explicit QQTClient(QObject *parent = 0);
virtual ~QQTClient();
void SetServerIPAddress(QStringList ip) { m_serverIP = ip; }
void SetServerPort(quint32 p = 7079) { m_PORT = p; }
void installProtocol(QQTProtocol* stack);
void uninstallProtocol(QQTProtocol* stack);
QQTProtocol* installedProtocol();
void SendConnectMessage();
int SendDisConnectFromHost();
signals:
void signalConnecting();
void signalConnectSucc();
void signalConnectFail();//
void signalDisConnectSucc();//maybe
void signalDisConnectFail();//
void signalUpdateProgress(qint64 value);
private slots:
void domainHostFound();
void socketStateChanged(QAbstractSocket::SocketState);
void socketErrorOccured(QAbstractSocket::SocketError);
void socketConnected();
void socketDisconnect();
void updateProgress(qint64);
protected slots:
void readyReadData();
private:
void connectToSingelHost();
/*
* TODO:如果文件传输影响到了UI线程那么需要将QTcpSocket局部变量化
* 阻塞UI不必考虑此处
* 非阻塞UIUI却工作很慢考虑此处。
*/
//QTcpSocket* m_sock;
QQTProtocol* m_protocol;
quint32 eConType;
QStringList m_serverIP;
quint32 m_PORT;
};
#endif // QQT_CLIENT_H