Open sue602 opened 4 months ago
你加载成功了的,只是要带包名……你可以用pb.types看看有哪些类型加载进来了
regards, Xavier Wang.
sue602 @.***>于2024年3月25日 周一22:40写道:
有文件1,文件名为 a.proto 内容如下
syntax = "proto2"; option java_package = "bf.message.game"; option java_outer_classname = "AntiqueMessage";
package bf.messages.game.EngineMessage;
message MsgGetReq_55012{ optional CommonMsgMessage.MsgResources res= 1; optional int64 time=2; } message MsgGetResp_55012{
}
有文件2,文件名为 b.proto 内容如下
syntax = "proto2"; option java_package = "bf.message.game"; option java_outer_classname = "CommonMsgMessage";
package bf.messages.game.CommonMsgMessage;
message MsgResources { optional int32 id = 1; optional string num = 2; }
加载:
local pb = require "pb" local protoc = require "protoc" local pbdir = "./" local protofiles = {a.proto,b.proto} protoc:addpath(pbdir)
for _, proto_filename in ipairs(protofiles) do local proto = protoc.new() proto:addpath(pbdir) proto:loadfile(proto_filename) end
local dd = {res= {id=1,num=3}, time= 3} local bytes = pb.encode("MsgGetReq_55012", dd) -- 这样加载失败 -- local bytes = pb.encode("AntiqueMessage.MsgGetReq_55012", dd) -- 这样也是失败的
请问下要如何才能正确加载这种有import引用呢, 感谢
— Reply to this email directly, view it on GitHub https://github.com/starwing/lua-protobuf/issues/263, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA36M34WMUOVBWNRAGZG33Y2AZNNAVCNFSM6AAAAABFHENSQGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIYDKOJSGA4TAMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
有文件1,文件名为 a.proto 内容如下
有文件2,文件名为 b.proto 内容如下
加载:
请问下要如何才能正确加载这种有import引用呢, 感谢