Send custom derived class via RPC

Options
Malrig
Malrig
I have a base class called action which has many derived classes for each different action.

I would like to register one method of serialisation/deserialisation for the base class and then use that for all derived classes. This would use a serialise/deserialise function defined in the derived class itself.

I would like to do this because I will have many different action classes and they will each have different sets of data defined in them.

I have tried to do this but I believe it checks for the Type strictly and does not consider sub-types.

Do you have any recommendations for how I could sort this without having to tell the Action class about any networking (I want to separate it from any networking at all).

One method I though of is that I could write a wrapper class for RPCs which can check the type itself and then call the RPC if it detects a subclass of action and provide the byte code manually. But I would prefer if I used some built in functionality than writing another class.

Thanks