Skip to content

Commit

Permalink
pb netpack 考虑多实例的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
huahua132 committed Dec 6, 2024
1 parent 2b27285 commit e6f2579
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lualib/skynet-fly/netpack/pb_netpack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local pcall = pcall
local assert = assert
local tostring = tostring
local setmetatable = setmetatable
local pairs = pairs

local g_instance_map = {}

Expand All @@ -17,27 +18,35 @@ 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文件
--------------------------------------------------------------------------
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
--------------------------------------------------------------------------
--按包名方式编码
--------------------------------------------------------------------------
Expand Down

0 comments on commit e6f2579

Please sign in to comment.