Closed Beider closed 3 years ago
In scope of this bug we also want to extend the DataConverter registry in MDStatics. A method to add custom converters should be added so we don't need to add new MDRpc and MDRset with custom convert parameters as well.
Something like,
MDStatics.AddDataConverter(Type ConverterForType, IMDDataConverter TheConverterInstance)
We should consider having two sending modes, if everything is inside System or Godot namespace we send as is. If anything is outside of that namespace we send with data converters. This would allow for enum/custom class support.
Would the mode be detected automatically based on the params?
I suppose, we can just do a namespace check on all of the parameters, if any parameter is outside of the Godot or System namespace we send in Data Converter mode, if not we just send with a standard Rpc call. We can at least test it, I have no idea how that would work if you send a Godot enum across the network, would have to test it. Maybe we also have to do an enum check to see that there are no enums.
Yeah seems like that's the right approach, enum check and namespace check
By default you can't send custom classes or lists with RPC, it would not be difficult to add a feature to MDRpc where if it detects a custom class or a list we automatically try to resolve the relevant converter or in the case of a list send it as a special mode so it is reassembled as a list on the other end.
Suggested Implementation
List<List<string>>
would work)This should allow us to send any type of data with MDRpc
More Detail
One way to do this would be to just implement something like a command replicator that we already have. You would have an enum describing what is being sent and add length as well. So for instance if you send a
Dictionary<string, List<MyClass>>
and you have two string keys + two custom classes for each string key the data might look something like this.