Open BenediktBurger opened 4 months ago
More elaborate discussion of the different methods.
The payload of the LECO message is the binary data, without any (pre-defined) other information.
From the LECO side quite simple: put the binary data in one or several payload frames (several for several binary objects).
example mehod (based on PyLECO):
current_message: Message # contains the LECO message
additional_response: bytes # will later contain the additional, binary, response
def method_with_binary(json_parameter):
binary_data = current_message.payload[1]
result = do_something(json_parameter, binary_data)
additional_response = result
return None
# afterwards the additional_response has to be added to the response message before sending
None
?) and there are additional frames?Encode your binary data to a string and use that as a parameter for JSON-RPC.
Sometime you have to transmit binary data, like an image. JSON (our main encoding scheme) does not support binary data. What do we recommend?
Several options, which are all compatible with current LECO definitions:
All three approaches have their advantages and disadvantages. I guess the choice depends on the circumstances. Here I want to present them, maybe we can recommend one or the other, or even all three as