Skip to main content

Protocol buffers

Protobuf is a data transmission protocol used for communication between game clients and services. Typically, data is transmitted in JSON API format, which is a common and easy-to-use method. However, one of the drawbacks of this method is that large amounts of unencrypted data can be easily exploited. To address this issue, Google defined the Protobuf protocol, which is specifically designed for data transmission.

Before transmission, data is encoded into binary format, which saves on transmission size and makes it difficult to change the content. This helps to prevent cheating and data tampering in games.

Please read docs https://protobuf.dev/overview/ to learn more about protocol buffer

Create protocol buffers

Open Liveops tools and select Protocol buffers on the sidebar (https://liveops.oneb.tech/protobuf)

Proto name Blueprint is a special proto, it is generated from blueprint schemas

To work with Player and game scripts you need to create by yourself if want to use binary API

Click the button + New proto and input the proto name

Download and install the Protobuf compiler

To compile the protobuf compiler from the source code, please refer to the following instructions. Alternatively, you can quickly obtain the protobuf compiler by following these steps:

1 install vcpkg

2 install protobuf

  • On Windows, use the following command: vcpkg install protobuf:x64-windows-static-md
  • On MacOS, use the following command: vcpkg install protobuf:x64-osx
  • Verify the installation in the folder vcpkg/packages/.../tools/protobuf

Compile proto

Open Liveops tools and select Protocol buffers on the sidebar (https://liveops.oneb.tech/protobuf)

click the download button download to obtain the file GAME_ID.proto

Copy the *.proto file to the tool folder and run the following command:

  • To compile C++ protoc --proto_path=. --cpp_out=. GAME_ID.proto

  • to compile C# protoc --proto_path=. --csharp_out=. GAME_ID.proto

  • To compile js:

    • install node package protobufjs-cli

    • use the following command:

      pbjs -t static-module -w commonjs --keep-case -o bundle.js ./proto/DEMO.proto

      pbts -o bundle.d.ts bundle.js

After running the command, the generated files (.cs or .cpp or .js) should be copied to your project.