From 076f6ed497ae2a7f1d6fd37e66d621ea29d9c589 Mon Sep 17 00:00:00 2001 From: Blank Date: Sat, 2 Nov 2024 16:24:52 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=A2=9E=E5=8A=A0]1.=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=89=BE=E5=88=B0=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E7=9A=84=E8=AD=A6=E5=91=8A=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Network/Network/ProtoMessageIdHandler.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Runtime/Network/Network/ProtoMessageIdHandler.cs b/Runtime/Network/Network/ProtoMessageIdHandler.cs index 1ad18b9..85bf4b0 100644 --- a/Runtime/Network/Network/ProtoMessageIdHandler.cs +++ b/Runtime/Network/Network/ProtoMessageIdHandler.cs @@ -24,6 +24,12 @@ public static class ProtoMessageIdHandler /// 请求的类型 public static Type GetReqTypeById(int messageId) { + if (ReqDictionary.Count <= 0) + { + Log.Warning("请先确认是否初始化 调用 ProtoMessageIdHandler.Init()"); + return null; + } + ReqDictionary.TryGetValue(messageId, out var value); return value; } @@ -35,6 +41,12 @@ public static Type GetReqTypeById(int messageId) /// 请求消息ID public static int GetReqMessageIdByType(Type type) { + if (ReqDictionary.Count <= 0) + { + Log.Warning("请先确认是否初始化 调用 ProtoMessageIdHandler.Init()"); + return 0; + } + ReqDictionary.TryGetKey(type, out var value); return value; } @@ -46,6 +58,12 @@ public static int GetReqMessageIdByType(Type type) /// 响应的类型 public static Type GetRespTypeById(int messageId) { + if (RespDictionary.Count <= 0) + { + Log.Warning("请先确认是否初始化 调用 ProtoMessageIdHandler.Init()"); + return null; + } + RespDictionary.TryGetValue(messageId, out var value); return value; } @@ -57,6 +75,12 @@ public static Type GetRespTypeById(int messageId) /// 响应消息ID public static int GetRespMessageIdByType(Type type) { + if (RespDictionary.Count <= 0) + { + Log.Warning("请先确认是否初始化 调用 ProtoMessageIdHandler.Init()"); + return 0; + } + RespDictionary.TryGetKey(type, out var value); return value; }