OperationRequestParameters how to put a custom struct in C++

xuelihong797998
edited August 2013 in Native
a C++ struct like:
struct a {
string m1;
int m2;
};
how to put the c++ struct into OperationRequestParameters?

Comments

  • Hi.
    You have 2 options:
    a) Don't serialize the struct itself, but only it's members + some code, that informs you, when received, that you should interpret the data as an instance of struct a.
    b) Use Photons CustomType interface to add that struct as a supported type to Photon. Please refer to the API doc of Common::CustomType, Common::CustomTypeBase and Common::CustomTypeFactory inside the Client SDKs doc folder and to the example implementation SampleCustomType in demo_advanced.

    In both cases you should of course only serialize those members of the class that are actually needed to reconstruct the struct on another client and not just blindly send the complete struct to avoid wasting resources by sending unneeded data.