Godot Version
4.4
Question
I’m implementing Steamworks API for a P2P multiplayer game in Godot using C#. First of all, the GodotSteam Addon is not available in C#, so I’m having to use bindings.
To send and receive P2P packets, the data obviously needs to be serialized. From what I’ve seen, GDNative methods var_to_bytes and bytes_to_var would be the best, since their implementation is also designed for this.
It turns out that none of these methods are in C#, ok, I created bindings for them.
When using GodotSteam to receive packets, packets arrive to me as a dictionary of <string, Variant>.
When sending the data, I’m creating dictionaries for them, and serializing them using the var_to_bytes binding. It turns out that with this binding, I can only serialize Variant or compatible objects.
In the VariantUtils class, I have the CreateFromDictionary method, but it returns an object of the godot_variant class, which is not compatible with the Variant class.
Is there a solution for this? Should I modify my solution so that I stop sending dictionaries and find another way?
I looked for other serialization methods, I found a lib called MessagePack, which seems to be extremely fast, but I couldn’t find anywhere if their extremely fast method is suitable for communications in multiplayer games. Their comparisons are with Json serializers.
Another solution would be to do this entire part of the code in GDScript, but I end up being a bit insistent.