# pbtool **Repository Path**: blanco1990/pbtool ## Basic Information - **Project Name**: pbtool - **Description**: 类 google protobuf 协议及生成工具 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 3 - **Created**: 2024-04-28 - **Last Updated**: 2024-04-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: 工具 ## README # pbtool 类`google protobuf`协议及生成工具 ## 依赖 - [python 3.x](https://www.python.org/) - [Git for Windows](https://gitforwindows.org/)(非必须,可在`win`下运行`shell`命令和脚本) ## 支持语言 - [erlang](examples/erlang) - [golang](examples/golang) - [typescript](examples/typescript/CocosCreator)(Cocos Creator) ## 使用方法 编辑`conf.py`配置文件 运行协议生成脚本 ```shell python main.py ``` ## 协议描述文件 协议以`message 协议名(协议ID)`开头,回车后以左大括号`{`加回车,然后是具体的协议字段,最后以右大括号` }`加回车结束 协议字段选项有3种格式:required repeated optional - required 必填字段 - repeated 列表字段 - optional 可选字段 具体协议字段 字段选项 字段类型 字段名称:如`required string uname` 协议类型有:u8 i8 u16 i16 u32 i32 u64 i64 f32 f64 string 自定义 协议示例: ```protobuf message GoodsItem(2010) //物品数据 { required u32 id //物品ID required u16 num //物品数量 } message GoodsList(2020) //物品列表 { repeated GoodsItem goods //物品列表 } ``` 具体可以看 [这里](examples),里面有各语言的`socket`和`websocket`的服务端及客户端示例代码