<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>protobuf - 标签 - cfanzp学习笔记</title>
    <link>https://cfanzp008.github.io/tags/protobuf/</link>
    <description>protobuf - 标签 - cfanzp学习笔记</description>
    <generator>Hugo -- gohugo.io</generator><language>zh-CN</language><managingEditor>cfan.zp@qq.com (cfanzp)</managingEditor>
      <webMaster>cfan.zp@qq.com (cfanzp)</webMaster><lastBuildDate>Tue, 30 Aug 2022 08:36:15 &#43;0800</lastBuildDate><atom:link href="https://cfanzp008.github.io/tags/protobuf/" rel="self" type="application/rss+xml" /><item>
  <title>lua-pbc(lua的protobuf库)如何使用？</title>
  <link>https://cfanzp008.github.io/lua-pbc/</link>
  <pubDate>Tue, 30 Aug 2022 08:36:15 &#43;0800</pubDate>
  <author>作者</author>
  <guid>https://cfanzp008.github.io/lua-pbc/</guid>
  <description><![CDATA[lua-pbc(lua的protobuf库)如何使用？ lua-pbc是什么? lua-pbc,即lua protocol buffer fro c,是云风写的一个给lua使用的protobuf封包解包的库,如果你想用skynet来写游戏等服务端应用，lua-pbc是不错的选择。
lua-pbc github地址为: https://github.com/cloudwu/pbc
关于pbc的设计，大家可以看一下云风的博客: https://blog.codingnow.com/2011/12/protocol_buffers_for_c.html
lua-pbc如何使用？ 这里有几个接个api需要熟悉一下
编写protobuf的proto文件 User.proto
1 2 3 4 package tutorial; message User { optional string name = 1; } 引入模块protobuf
1 local pb = require &#34;protobuf&#34; 注册文件
1 pb.register_file &#34;User.pb&#34; encode
1 2 3 4 local msg_table = { name = &#34;test1&#34; } pb.encode(&#34;tutorial.User&#34;,msg_table}, decode
1 local msg_table = pb.decode(&#34;tutorial.Person&#34;, buf) 使用感受 lua-pbc使用了很长一段时间，官方skynte升级支持lua5.4以后，pbc还是可以正常工作的。 pbc的接口设计是比较简洁的，用起来也非常方便。想深入了解的同学，建议去看看源码。
参考 pbc: https://github.com/cloudwu/pbc pbc binding lua: https://github.]]></description>
</item>
</channel>
</rss>
