You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
973 B
C++
54 lines
973 B
C++
#ifndef CLIENTSESSION_H
|
|
#define CLIENTSESSION_H
|
|
|
|
#include <QThread>
|
|
#include <QTcpSocket>
|
|
#include <QByteArray>
|
|
#include <QTimer>
|
|
class ClientSession : public QThread
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
ClientSession(int ID, QObject *parent);
|
|
~ClientSession();
|
|
|
|
void forceclose();
|
|
|
|
void sendPackage(QByteArray &ndata);
|
|
QString getInfo(QString &address, qint16 &port, QString perrname)
|
|
{
|
|
address = mAddress;
|
|
port = mPort;
|
|
perrname = mPeerName;
|
|
return mSocketName;
|
|
};
|
|
public slots:
|
|
void readyRead();
|
|
void disconnect();
|
|
void slotErrorHandle(QAbstractSocket::SocketError err);
|
|
void slotTimerClose();
|
|
|
|
signals:
|
|
void dataReceived(int, QByteArray);
|
|
void disconnected(int);
|
|
void disconnectedTg(QString);
|
|
void sgConnectState(QVariantMap);
|
|
private:
|
|
void socketClose();
|
|
|
|
private:
|
|
QTcpSocket mSocket;
|
|
int mSocketDescriptor;
|
|
|
|
bool mbClosed;
|
|
QTimer mtimerClose;
|
|
|
|
QString mPeerName;
|
|
QString mAddress;
|
|
qint16 mPort;
|
|
QString mSocketName;
|
|
};
|
|
|
|
#endif // CLIENTSESSION_H
|