#ifndef __LIBTCP_H__ #define __LIBTCP_H__ #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef struct tagTP_TCP_CLIENT_PARAM{ QString user_; // 用户名 QString host_ip_; // 服务器地址 quint16 port_{6677}; // 服务器端口 bool enable_ssl_{false}; // 是否启用SSL bool auto_reconnect_{false}; // 是否自动重连 }TP_TCP_CLIENT_PARAM; typedef struct tagTP_TCP_SERVER_PARAM{ QString host_ip_; // 监听地址, *为所有可用地址 quint16 port_{6677}; // 监听端口 bool enable_ssl_{false}; // 是否启用SSL QList user_list_; // 允许的用户列表。空代表无用户验证 }TP_TCP_SERVER_PARAM; typedef enum TpServerStatus { ON_RUNNING = 0, ON_SHUTDOWN = 1, }TpServerStatus; typedef struct tagTP_CLIENT_STATUS { QString client_name_; QString client_ip_; QString host_ip_; QAbstractSocket::SocketState status; int session_id_; QDateTime last_active_time_; }TP_CLIENT_STATUS; typedef QMap ClientsStatusMap; typedef enum TpProtoParserStatus { ON_PARSER_INIT = 0, ON_PARSER_HAED = 1, ON_PARSER_BODY = 2, }TpProtoParserStatus; typedef struct tagTP_PROTOCOL_HEAD { quint8 version_; quint8 magic_; quint16 server_; quint32 length_; }TP_PROTOCOL_HEAD; class TP_PROTOCOL_MESSAGE { public: TP_PROTOCOL_MESSAGE(){} ~TP_PROTOCOL_MESSAGE(){} public: TP_PROTOCOL_HEAD head; QJsonObject body; }; Q_DECLARE_METATYPE(QSharedPointer) #ifndef LPQSHAREDPOINTERQBYTEARRAY #define LPQSHAREDPOINTERQBYTEARRAY Q_DECLARE_METATYPE(QSharedPointer) #endif Q_DECLARE_METATYPE(QSharedPointer) #endif //__TP_PROTOCOL_H__