-
Notifications
You must be signed in to change notification settings - Fork 0
/
服务器交互逻辑.txt
81 lines (67 loc) · 5.35 KB
/
服务器交互逻辑.txt
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
70
71
72
73
74
75
76
77
78
79
80
81
//账号检测
void newClient_check(); //账号登录
void lostClient_check(); //删除在线的人
void readMessage_check(); //读取账号信息
void sendMessage_check(); //发送信息
//消息转发
void newConnect_news(); //新客户端连接
void sendMessage_news(QString information); //发送消息
void readMessage_news(); //接收消息
void lostClient_news(); //删除聊天
//初始化界面
void newConnect_surface(); //新客户端连接
void sendMessage_surface(QString initMsg); //发送消息
void readMessage_surface(); //接收消息
void lostClient_surface(); //删除
//群聊界面
void newConnect_Chatnews(); //新客户端连接
void sendMessage_Chatnews(QString information); //发送消息
void readMessage_Chatnews(); //接收消息
void lostClient_Chatnews(); //删除聊天
//服务器销毁
void destoryServer_check();
/************************账号检测 5555端口********************/
//network
QTcpServer *server_check; //服务
QTcpSocket *client_check; //临时客户端
QList<QTcpSocket *> clients_check; //客户端列
//标志
bool listenFlag_check = false; //5555端口监听
bool clientJoinUp_check = false; //客户端加
bool loginSuccessFlag_check = false; //登陆成功标志
//反馈消息
void feedbackMessage(QString msg);
/**********************转发消息 6666端口**********************/
//network
QTcpServer *server_news; //服务器
QTcpSocket *client_news; //临时客户
QList<QTcpSocket *> *clients_news; //客户端列表
//标志
bool listenFlag_news = false; //6666端口监听
bool clientJoinUp_news = false; //客户端加入
bool loginSuccessFlag_news = false; //登陆成功标志
/********************初始化界面 7777端口********************/
//network
QTcpServer *server_surface; //服务器
QTcpSocket *client_surface; //临时客户端
QList<QTcpSocket *> *clients_surface; //客户端列表
QString initMsg; //初始化界面的消息
//标志
bool listenFlag_surface = false; //7777端口监听
bool clientJoinUp_surface = false; //客户端加入
bool loginSuccessFlag_surface = false; //登陆成功标志
/*******************群聊 8888端口****************************/
//network
QTcpServer *server_Chatnews; //服务器
QTcpSocket *client_Chatnews; //临时客户
QList<QTcpSocket *> *clients_Chatnews; //客户端列表
//标志
bool listenFlag_Chatnews = false; //8888端口监听
bool clientJoinUp_Chatnews = false; //客户端加入
bool loginSuccessFlag_Chatnews = false;
在进行配置前,关闭防火墙 新建配置 开放四个端口
寻址ipv4地址,放在客户端用于连接
客户端,用户的登录和注册操作会连接5555端口
登录操作:连接5555端口,执行client_check函数,获取客户端socket,进行信号连接。一旦断开连接,执行lose_client函数
一旦有消息可读,执行read_message函数。然后在临时客户端末尾添加新客户的socket
读取消息:(注意一下用户端发送的消息)若登陆成功 给用户发送结果(注意客户端的代码研究)