-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilebase.h
45 lines (38 loc) · 908 Bytes
/
filebase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef FILEBASE_H
#define FILEBASE_H
#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
#include <QList>
#include <QDataStream>
#include <QDateTime>
enum MsgType
{
MsgTypeInvalid = 0,
MsgTypeFile,
MsgTypeDel,
MsgTypeRename
};
class FileBase : public QObject
{
Q_OBJECT
public:
explicit FileBase(QObject *parent = nullptr);
signals:
void doFile(const QString& filename, const QByteArray& data);
void doDel(const QString& filename);
void doRename(const QString& filename1, const QString& filename2);
public slots:
// 新客户端请求处理函数
void onNewConnection();
// socket相关
void onConnected();
void onDisConnected();
void onError(QAbstractSocket::SocketError socketError);
void onReadReady();
private:
QTcpServer* server;
QList<QTcpSocket*> clients;
quint32 LastsizePack = 0;
};
#endif // FILEBASE_H