kRPC: Control the game using C#, C++, Java, Lua, Python...

kRPC: Control the game using C#, C++, Java, Lua, Python...

7.8k Downloads

Encoding of default RPC parameters in JSON service definition files

maroider opened this issue ยท 4 comments

commented

Background

Some time ago, I decided I wanted to create a client library for the Rust programming language. At first I thought the easiest way would be to integrate with the existing framework for doing this in krpc's repo. Alas, I could not get bazel to work at all and I abandoned that approach. Instead, I decided to parse the output of krpc-servicedefs and generate a client library on my own. With some trial-and-error (and referencing the documentation a bunch), I was able to create a library that does some things correctly (or at least seems to).

The actual issue at hand

Some RPC's parameters have a default value that should be set by the library. Unfortunately, I can't seem to decipher how exactly I'm supposed to use the provided values. It's fairly obvious that they're base64-encoded, but I'm not having much luck beyond that.

commented

afaik the base-64 is the pre-encoded protobuf value, so no need to do any additional encoding. Just extract the binary from the base64 encoding and send it as your value as is.

commented

In that case you should be able to decode the binary using protobufs internal decoder for the different types that are defined in the servicedefs, or am I missing something?

commented

That might just work, but I'd also like to be able to have my generated documentation show what the default values are. KRPC's own documentation does this.

commented

The default value is indeed protobuf encoded. The kRPC documentation using the python protobuf library to decode them for display. https://github.com/krpc/krpc/blob/master/tools/krpctools/krpctools/utils.py#L56