-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
解码的过程碰到一个奇怪的问题 #16
Comments
我怀疑服务端的import_proto_file这个函数未能成功。可能路径不对。这个导入失败是否有返回值? |
查到问题了。。原因特别奇葩。不知道你用过skynet么 skynet.start(function() local pb = require("luapbintf") pb.import_proto_file("login.proto") skynet.start(function() end) 把decode的部分拿到外面。就可以正常解编码了。。。 |
最后解决了。然后得出一个神奇的结论 下面的版本是我改了后。测试在skynet下可以正常解码 skynet.start(function() |
协议体
syntax = "proto3";
package login;
message login {
string account = 1 ;
string password = 2 ;
int32 sdkid = 3 ;
}
发送下面这个包,客户端发完后直接解包是正常解出来的
send pbstr:0A 04 6B 69 6E 67 12 06 31 31 31 31 31 31 18 01
send:cmd(login.login) check(0) len(24) msg->{
["password"] = "111111",
["account"] = "king",
["sdkid"] = 1,
}
服务端接收到这个包的打印
recv pbstr:0A 04 6B 69 6E 67 12 06 31 31 31 31 31 31 18 01
recv:cmd(login.login) check(0) msg->"
king111111"
这个msg里面直接是个字符串了。
我看了下。
local msg = pb.decode(cmd, pbstr)
这里msg解码后得到的是一个字符串。
解码失败会直接得到tostring的结果吗?使用的协议文件是同一个。怎么会解码失败呢
The text was updated successfully, but these errors were encountered: