From e6f2579624a7fbeeb8101405ff5f9334f5c8116b Mon Sep 17 00:00:00 2001 From: huahua132 <958677003@qq.com> Date: Fri, 6 Dec 2024 15:16:50 +0800 Subject: [PATCH] =?UTF-8?q?pb=20netpack=20=E8=80=83=E8=99=91=E5=A4=9A?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lualib/skynet-fly/netpack/pb_netpack.lua | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lualib/skynet-fly/netpack/pb_netpack.lua b/lualib/skynet-fly/netpack/pb_netpack.lua index 18f4527e9..6bd84e17b 100644 --- a/lualib/skynet-fly/netpack/pb_netpack.lua +++ b/lualib/skynet-fly/netpack/pb_netpack.lua @@ -8,6 +8,7 @@ local pcall = pcall local assert = assert local tostring = tostring local setmetatable = setmetatable +local pairs = pairs local g_instance_map = {} @@ -17,7 +18,7 @@ function M.new(name) local m_name = name or "" local m_loaded = {} local m_pack_id_name = {} - + local m_p = protoc:new() local ret_M = {} -------------------------------------------------------------------------- --加载指定路径pb文件 @@ -25,19 +26,27 @@ function M.new(name) function ret_M.load(rootpath) for file_name,file_path,file_info in file_util.diripairs(rootpath) do if string.find(file_name,".proto",nil,true) then - protoc:loadfile(file_path) + m_p:loadfile(file_path) end end --记录加载过的message名称 - for name,basename,type in pb.types() do - if not string.find(name,".google.protobuf",nil,true) then - m_loaded[name] = true + for file_path, info in pairs(m_p.loaded) do + if info.message_type then + local package = info.package + for i = 1, #info.message_type do + local message = info.message_type[i] + m_loaded['.' .. package .. '.' .. message.name] = true + end end end - + return m_loaded end + + function ret_M.get_loaded() + return m_p.loaded + end -------------------------------------------------------------------------- --按包名方式编码 --------------------------------------------------------------------------