-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.h
67 lines (50 loc) · 1.45 KB
/
server.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
#ifndef SERVER_H
#define SERVER_H
#include <QTcpServer>
#include "blowfish.h"
#include "room.h"
class client;
class Dialog;
class room;
class server : public QTcpServer
{
Q_OBJECT
public:
BLOWFISH_CTX *ctx;
bool _encrypt;
explicit server(QWidget *widget, QObject *parent = 0);
bool doStartServer(QHostAddress addr, qint16 port);
void sendToUser(quint8 comm, QString message, QTcpSocket* &sok);
void sendTextMessToAll(QString name,QString mess);
void sendJoinNewUser(QString name);
void sendListRoom(QTcpSocket* &sok);
QVector<int> encrypt(QString str);
QString dencrypt(QVector<int> vec);
void sendOpenUdp(QString name);
int getClientCount();
void sendKeepAlive(QTcpSocket* &sok);
QStringList getUsersOnline() const;
void closeAllConnection();
bool isNameValid(QString name) const;
bool isNameUsed(QString name) const;
static bool running;
QList <room*> roomList;
signals:
void newRoom(QString);
public slots:
void sendMessageToAll(QString name,QString mess);
void onChangePasswd(BLOWFISH_CTX* ctx_, bool* encr_);
void sendCryptToAll(QString nam, QVector <int> vec);
void sendRemoveUser(QString name);
void stopServer();
void kick(QString name);
private slots:
void newUser();
void onRemoveUser(client*);
protected:
// void incomingConnection(int handle);
private:
QList <client *> _clients;
QWidget *_widget;
};
#endif // SERVER_H