Skip to content

Commit 7bf8a53

Browse files
committed
refactor(Discovery): 清理未使用的消息操作类型并修复代码格式
移除未使用的消息操作类型case分支,优化代码结构 修复日志输出块的代码格式问题
1 parent 2d8b765 commit 7bf8a53

File tree

1 file changed

+35
-60
lines changed

1 file changed

+35
-60
lines changed

GameFrameX.Launcher/StartUp/Discovery/AppStartUpDiscoveryCenter.cs

Lines changed: 35 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
// ==========================================================================================
2-
// GameFrameX 组织及其衍生项目的版权、商标、专利及其他相关权利
3-
// GameFrameX organization and its derivative projects' copyrights, trademarks, patents, and related rights
4-
// 均受中华人民共和国及相关国际法律法规保护。
5-
// are protected by the laws of the People's Republic of China and relevant international regulations.
6-
//
7-
// 使用本项目须严格遵守相应法律法规及开源许可证之规定。
8-
// Usage of this project must strictly comply with applicable laws, regulations, and open-source licenses.
9-
//
10-
// 本项目采用 MIT 许可证与 Apache License 2.0 双许可证分发,
11-
// This project is dual-licensed under the MIT License and Apache License 2.0,
12-
// 完整许可证文本请参见源代码根目录下的 LICENSE 文件。
13-
// please refer to the LICENSE file in the root directory of the source code for the full license text.
14-
//
15-
// 禁止利用本项目实施任何危害国家安全、破坏社会秩序、
16-
// It is prohibited to use this project to engage in any activities that endanger national security, disrupt social order,
17-
// 侵犯他人合法权益等法律法规所禁止的行为!
18-
// or infringe upon the legitimate rights and interests of others, as prohibited by laws and regulations!
19-
// 因基于本项目二次开发所产生的一切法律纠纷与责任,
20-
// Any legal disputes and liabilities arising from secondary development based on this project
21-
// 本项目组织与贡献者概不承担。
22-
// shall be borne solely by the developer; the project organization and contributors assume no responsibility.
23-
//
24-
// GitHub 仓库:https://github.com/GameFrameX
25-
// GitHub Repository: https://github.com/GameFrameX
26-
// Gitee 仓库:https://gitee.com/GameFrameX
27-
// Gitee Repository: https://gitee.com/GameFrameX
28-
// 官方文档:https://gameframex.doc.alianblank.com/
29-
// Official Documentation: https://gameframex.doc.alianblank.com/
30-
// ==========================================================================================
31-
1+
// ==========================================================================================
2+
// GameFrameX 组织及其衍生项目的版权、商标、专利及其他相关权利
3+
// GameFrameX organization and its derivative projects' copyrights, trademarks, patents, and related rights
4+
// 均受中华人民共和国及相关国际法律法规保护。
5+
// are protected by the laws of the People's Republic of China and relevant international regulations.
6+
//
7+
// 使用本项目须严格遵守相应法律法规及开源许可证之规定。
8+
// Usage of this project must strictly comply with applicable laws, regulations, and open-source licenses.
9+
//
10+
// 本项目采用 MIT 许可证与 Apache License 2.0 双许可证分发,
11+
// This project is dual-licensed under the MIT License and Apache License 2.0,
12+
// 完整许可证文本请参见源代码根目录下的 LICENSE 文件。
13+
// please refer to the LICENSE file in the root directory of the source code for the full license text.
14+
//
15+
// 禁止利用本项目实施任何危害国家安全、破坏社会秩序、
16+
// It is prohibited to use this project to engage in any activities that endanger national security, disrupt social order,
17+
// 侵犯他人合法权益等法律法规所禁止的行为!
18+
// or infringe upon the legitimate rights and interests of others, as prohibited by laws and regulations!
19+
// 因基于本项目二次开发所产生的一切法律纠纷与责任,
20+
// Any legal disputes and liabilities arising from secondary development based on this project
21+
// 本项目组织与贡献者概不承担。
22+
// shall be borne solely by the developer; the project organization and contributors assume no responsibility.
23+
//
24+
// GitHub 仓库:https://github.com/GameFrameX
25+
// GitHub Repository: https://github.com/GameFrameX
26+
// Gitee 仓库:https://gitee.com/GameFrameX
27+
// Gitee Repository: https://gitee.com/GameFrameX
28+
// 官方文档:https://gameframex.doc.alianblank.com/
29+
// Official Documentation: https://gameframex.doc.alianblank.com/
30+
// ==========================================================================================
31+
3232
using GameFrameX.NetWork.Abstractions;
3333
using GameFrameX.NetWork.HTTP;
3434
using GameFrameX.NetWork.Message;
@@ -112,17 +112,15 @@ protected override ValueTask PackageHandler(IAppSession session, IMessage messag
112112
{
113113
// 当需要打印心跳,或当前非心跳消息时才输出日志
114114
if (Setting.IsDebugReceiveHeartBeat || messageObject.Header.OperationType != MessageOperationType.HeartBeat)
115-
{
115+
{
116116
var serverInfo = _namingServiceManager.GetNodeBySessionId(session.SessionID);
117117
var from = serverInfo != null ? serverInfo.Type.ToString() : ServerType.ToString();
118118
LogHelper.Debug($"---收到[{from} To {ServerType}] {message.ToFormatMessageString()}");
119+
}
119120
}
120-
}
121121

122122
switch (messageObject.Header.OperationType)
123123
{
124-
case MessageOperationType.None:
125-
break;
126124
case MessageOperationType.HeartBeat:
127125
{
128126
// 心跳响应
@@ -135,10 +133,6 @@ protected override ValueTask PackageHandler(IAppSession session, IMessage messag
135133
SendMessage(session, response);
136134
return ValueTask.CompletedTask;
137135
}
138-
case MessageOperationType.Cache:
139-
break;
140-
case MessageOperationType.Database:
141-
break;
142136
case MessageOperationType.Game:
143137
{
144138
var reqConnectServer = (ReqConnectServer)messageObject.DeserializeMessageObject();
@@ -165,24 +159,7 @@ protected override ValueTask PackageHandler(IAppSession session, IMessage messag
165159
}
166160
}
167161
break;
168-
case MessageOperationType.GameManager:
169-
break;
170-
case MessageOperationType.Forbid:
171-
break;
172-
case MessageOperationType.Reboot:
173-
break;
174-
case MessageOperationType.Reconnect:
175-
break;
176-
case MessageOperationType.Reload:
177-
break;
178-
case MessageOperationType.Exit:
179-
break;
180-
case MessageOperationType.Kick:
181-
break;
182-
case MessageOperationType.Notify:
183-
break;
184-
case MessageOperationType.Forward:
185-
break;
162+
186163
case MessageOperationType.PlayerRegisterOnLine:
187164
{
188165
var reqRegisterPlayer = (ReqDiscoverCenterPlayerOnline)messageObject.DeserializeMessageObject();
@@ -194,7 +171,7 @@ protected override ValueTask PackageHandler(IAppSession session, IMessage messag
194171
case MessageOperationType.PlayerRegisterOffLine:
195172
{
196173
var reqRegisterPlayer = (ReqDiscoverCenterPlayerOffline)messageObject.DeserializeMessageObject();
197-
// 注册玩家
174+
// 注销玩家
198175
NamingPlayerManager.Instance.TryRemove(reqRegisterPlayer.PlayerId, out var playerInfo);
199176
LogHelper.Info($"注销玩家成功:{reqRegisterPlayer.PlayerId} {reqRegisterPlayer}");
200177
return ValueTask.CompletedTask;
@@ -234,8 +211,6 @@ protected override ValueTask PackageHandler(IAppSession session, IMessage messag
234211
SendMessage(session, respConnectServer);
235212
}
236213
break;
237-
default:
238-
throw new ArgumentOutOfRangeException();
239214
}
240215
}
241216

0 commit comments

Comments
 (0)