unity xlua protobuf

https://www.jianshu.com/p/d997e1f5e2ed

 

Post-project access xlua, do hot code updates. Which is any logical project requirements can be more heat, you can also add any fully functional. Wherein the message is used protobuf.
Because protobuf c # version of google need to serialize the message is good, and then used as c # classes. But this is not conducive to do very hot update code.
So we decided to pb access to xlua years. The authors have looked at xlua provides GitHub integration of pb.
Link https://github.com/chexiongsheng/build_xlua_with_libs

About integrate other libraries git says very clearly.
If this was the record about how to use
after xlua hotfix and so configured in c # side initialized when calling
Luaenv.AddBuildin ( "pb", XLua.LuaDLL.Lua.LoadLuaProfobuf) ;

main.lua load protobufmain.lua
protobufmain.lua:
- Core resolve
pb = The require "pb"
- added Protoc
Protoc = The require "protobuf.protoc"

- listen for messages - "Analysis
- here is listening c # existing network layer callback, is a series of binary message body
luadencode = The require" protobuf.prasemsg "
luadencode.init ()

- here to add a message structure, i.e. the message structure proto
- protoc: load (the message content string)
Protobuf the require = "protobuf.proto"
Protoc: Load (protobuf.allmsg)

Into binary
byte [] msg = pb.encode (msgname , msgcontent)

Binary conversion table
msgtabel = pb.decode (msgname, msgcontent)



Author: Jayden_JMN
link: https: //www.jianshu.com/p/d997e1f5e2ed
Source: Jane books
are copyrighted by the author. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.

Guess you like

Origin www.cnblogs.com/nafio/p/12370172.html