#ifndef __TP_RAW_CLIENTSESSION_H__ #define __TP_RAW_CLIENTSESSION_H__ #include #include #include #include typedef std::function RecvDataFunc; class lpRawClientSession : public QObject { Q_OBJECT public: lpRawClientSession(int ID, QObject *parent = 0); ~lpRawClientSession(); void setRecvCallBackFunc(RecvDataFunc func) { _func = func; }; void force_close(); Q_SLOT void on_data_to_send(int sess_id, QSharedPointer); QString getClientIP(); int getClientPort(); signals: void data_received(int, QSharedPointer); void sess_disconnected(int); private: void socket_close(); Q_SLOT void on_ready_read(); Q_SLOT void on_disconnect(); private: QTcpSocket *psocket_{ nullptr }; int socket_descriptor_; RecvDataFunc _func; }; #endif //__TP_RAW_CLIENTSESSION_H__