Skip to content

chore: add proto files - #6

Merged
TCL606 merged 6 commits into
eesast:devfrom
DragonAura:dev
Sep 28, 2022
Merged

chore: add proto files#6
TCL606 merged 6 commits into
eesast:devfrom
DragonAura:dev

Conversation

@DragonAura

@DragonAura DragonAura commented Sep 27, 2022

Copy link
Copy Markdown
Collaborator

Descriptions of this pull request:

初版Proto代码,至少没有任何语法错误、可以用protoc正常生成,但是可能存在诸多不完善的点。

@TCL606

TCL606 commented Sep 27, 2022

Copy link
Copy Markdown
Member

看你们现在的 proto,只有当 client 发出请求后,才能收到当前时刻场上的信息。这其实不太好,第一是不能保证不同client获得了相同的信息,不同client间会有信息差;第二是在server上会带来不必要的重复上锁。建议改成:

service AvailableService
{
    // 游戏开局调用一次的接口
    rpc AddPlayer(PlayerMsg) returns(stream MessageToClient); // 连接上后,就等待游戏开始;游戏开始后,server定时向client发送信息

    // 游戏过程中玩家获取信息的接口
    // rpc GetInfo(google.protobuf.Empty) returns (stream MessageToClient); // 这个不再需要
}

@Timothy-Liuxf Timothy-Liuxf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议采用 proto3 命名法习惯,例如 package 用小写+小数点、enum 全部大写、字段用小写加下划线,等等。其他的规则参见:
https://developers.google.com/protocol-buffers/docs/proto3#packages

@Timothy-Liuxf

Copy link
Copy Markdown
Member

建议采用 proto3 命名法习惯,例如 package 用小写+小数点、enum 全部大写,等等。详情参见: https://developers.google.com/protocol-buffers/docs/proto3#packages

按照这种习惯的好处是,protobuf 会自动把名字转换成对应目标语言的习惯命名法

@DragonAura

Copy link
Copy Markdown
Collaborator Author

已经按xfgg和clgg的建议都修改了

TCL606
TCL606 previously approved these changes Sep 27, 2022

@Timothy-Liuxf Timothy-Liuxf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

刚看到这里出了 CI 的问题,简单说一下吧。关于 protobuf 生成的 C++ 代码,里面用的是 Google 的风格代码。
如果过不了 CI 的话,可以用下面链接里的方法忽略 CI 对这个文件夹内文件的检查:
https://github.com/marketplace/actions/clang-format-lint#exclude
或者也可以在生成的 proto 子文件夹里加一个 .clang-format,设置成 Google 风格。


不过相对来说更好的方法是不把 protobuf 生成的 c++ 代码文件 push 到 git 仓库里,而是在仓库中删掉 c++ 代码文件,并使用 gitignore 忽略掉。当把仓库拉下来的时候,本地使用初始化脚本再将 c++ 代码文件生成出来。不过这样做需注意 protobuf 的版本问题,保证一致的版本号。此外在日后发给选手的时候,为了避免让选手安装 protobuf 的麻烦,需要把 c++ 文件发给选手。如果运维组写出来了自动化下载器的话,也许需要在 CI 里生成 c++ 文件后上传服务器让选手下载(

Comment thread dependency/proto/cpp_output.sh Outdated
Co-authored-by: Timothy Liu <liuxf19@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants