-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChatServer.h
58 lines (51 loc) · 1.95 KB
/
ChatServer.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
#ifndef CHATSERVER_H
#define CHATSERVER_H
#include <QObject>
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QTcpSocket>
#include "ChatMessages.h"
#include "ClientList.h"
#include "configmanager.h"
#include "logger.h"
class ChatServer : public QObject
{
Q_OBJECT
private:
QTcpServer *m_tcpServer;
quint16 m_nextBlockSize;
quint16 m_port;
GeneralClientList m_clientList;
void processMessage(ChannelMessage *msg);
void processMessage(AuthorizationRequest *msg, QTcpSocket *socket);
void processMessage(DisconnectMessage *msg);
void processMessage(RegistrationRequest *msg, QTcpSocket *socket);
void processMessage(ChannelListRequest *msg, QTcpSocket *socket);
void processMessage(ChannelJoinRequest *msg, QTcpSocket *socket);
void processMessage(ChannelLeaveMessage *msg);
void processMessage(ChannelCreateRequest *msg);
void processMessage(ChannelThemeChanged *msg);
void processMessage(ClientStatusChanged *msg);
void processMessage(UserInfoRequest *msg, QTcpSocket *socket);
void processMessage(UserInfoChanged *msg);
void processMessage(PasswordChangeRequest *msg);
void sendMessageToClient(QTcpSocket *socket, ChatMessageBody *msgBody);
void sendMessageToClient(QString username, ChatMessageBody *msgBody);
void sendMessageToChannel(QString channelName, ChatMessageBody *msgBody);
QString getSendableState(QString clientName);
public:
enum { defaultPort = 33033 };
explicit ChatServer(QObject *parent = 0);
bool startServer(const quint16 nPort);
void stopServer(const QString &shutdownReason = "");
signals:
void serverLog(ErrorStatus, QString &message);
void channelLog(QString &name, QString &message);
void updateTable(QString tablename);
private slots:
void serverGotNewConnection();
void serverGotNewMessage();
void replyLog(ErrorStatus status, QString &str);
public slots:
void setConfig(ChatServerConfig *pointer);
};
#endif // CHATSERVER_H