Skip to content

Commit

Permalink
[增加]1. 增加没有找到数据的时候的警告打印
Browse files Browse the repository at this point in the history
  • Loading branch information
AlianBlank committed Nov 2, 2024
1 parent 32dc36b commit 076f6ed
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Runtime/Network/Network/ProtoMessageIdHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public static class ProtoMessageIdHandler
/// <returns>请求的类型</returns>
public static Type GetReqTypeById(int messageId)
{
if (ReqDictionary.Count <= 0)
{
Log.Warning("请先确认是否初始化 调用 ProtoMessageIdHandler.Init()");
return null;
}

ReqDictionary.TryGetValue(messageId, out var value);
return value;
}
Expand All @@ -35,6 +41,12 @@ public static Type GetReqTypeById(int messageId)
/// <returns>请求消息ID</returns>
public static int GetReqMessageIdByType(Type type)
{
if (ReqDictionary.Count <= 0)
{
Log.Warning("请先确认是否初始化 调用 ProtoMessageIdHandler.Init()");
return 0;
}

ReqDictionary.TryGetKey(type, out var value);
return value;
}
Expand All @@ -46,6 +58,12 @@ public static int GetReqMessageIdByType(Type type)
/// <returns>响应的类型</returns>
public static Type GetRespTypeById(int messageId)
{
if (RespDictionary.Count <= 0)
{
Log.Warning("请先确认是否初始化 调用 ProtoMessageIdHandler.Init()");
return null;
}

RespDictionary.TryGetValue(messageId, out var value);
return value;
}
Expand All @@ -57,6 +75,12 @@ public static Type GetRespTypeById(int messageId)
/// <returns>响应消息ID</returns>
public static int GetRespMessageIdByType(Type type)
{
if (RespDictionary.Count <= 0)
{
Log.Warning("请先确认是否初始化 调用 ProtoMessageIdHandler.Init()");
return 0;
}

RespDictionary.TryGetKey(type, out var value);
return value;
}
Expand Down

0 comments on commit 076f6ed

Please sign in to comment.