-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.h
69 lines (57 loc) · 1.65 KB
/
client.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef CLIENT_H
#define CLIENT_H
#include <QObject>
#include "server.h"
#include <QTimer>
class server;
class client : public QObject
{
friend class server;
Q_OBJECT
public:
// BLOWFISH_CTX *ctx;
// bool _encrypt;
static int countClient;
static const quint8 comAutchReq = 0;
static const quint8 comGetNick = 1;
static const quint8 comMessageToAll = 20;
static const quint8 comMessageAllEncrypt = 21;
QString _name;
QTcpSocket *soket;
explicit client(int desc, server *serv, QObject *parent = 0);
explicit client(QTcpSocket *sok, server *serv, QObject *parent = 0);
static const QString constNameUnknown;
void write(QByteArray &block );
void doSendUsersOnline() const;
QString decrypt(QVector <int> data);
void sendAddr(QHostAddress addr, quint16 port);
void init();
~client();
QString getName() const {return _name;}
bool getAutched() const {return _isAutched;}
void close();
signals:
void sendMessageAll(QString name, QString mess);
void addUserToGui(QString name);
void removeUser(client *client);
void removeUserFromGui(QString name);
void messageToGui(QString name, QString mess);
void sendCrypt(QString nam, QVector <int> vec);
void newWait(QString name,QString name2);
public slots:
private slots:
void alive();
void onConnect();
void onConnectSoket();
void onDisconnect();
void onReadyRead();
void onError(QAbstractSocket::SocketError socketError) const;
private:
bool keepAlive;
QTcpSocket *_sok;
QTimer *timer;
server *_serv;
quint16 _blockSize;
bool _isAutched;
};
#endif // CLIENT_H