Hey everyone!
For the native C++ photon engine when you call opRaiseEvent(stuff..) for the "event code" is there a reserved codes? I would like to send custom messages with unique event codes.
The codes 201-255 are reserved for Photons internal usage.
The codes 0-200 can be used by the user code for custom events.
Our recommendation is to just start with code 0 and to count up from there.
@Kaiserludi thank you!
If you have a moment I'd like to ask you if you have a most efficient way to pass custom packets.
Right now I have a "NetCore" full of custom structs and when I send the information I just memcpy into an array of bytes then send it. then vice versa for reading.
Do you know of anything more efficient with the API and custom structs?
You could let your custom structs inherit from ExitGames::Common::CustomType<typeCode> so that you can pass the custom struct itself to opRaiseEvent() to avoid the additional copy into / out of the byte array.
pathToPhotonClientSDK\Demos\demo_typeSupport contains the class SampleCustomType as an example implementation of a custom type.
Another approach would be a union:
struct CustomStruct
{
int member1;
short member2;
long long member3;
};
union CustomUnion
{
CustomStruct type;
unsigned char arr[sizeof(CustomStruct)];
};
Comments
The codes 201-255 are reserved for Photons internal usage.
The codes 0-200 can be used by the user code for custom events.
Our recommendation is to just start with code 0 and to count up from there.
If you have a moment I'd like to ask you if you have a most efficient way to pass custom packets.
Right now I have a "NetCore" full of custom structs and when I send the information I just memcpy into an array of bytes then send it. then vice versa for reading.
Do you know of anything more efficient with the API and custom structs?
You could let your custom structs inherit from ExitGames::Common::CustomType<typeCode> so that you can pass the custom struct itself to opRaiseEvent() to avoid the additional copy into / out of the byte array.
For more information on the custom type APIs please see the API reference for CustomType at https://doc-api.photonengine.com/en/cpp/current/a04866.html, for CustomTypeBase at https://doc-api.photonengine.com/en/cpp/current/a04870.html and for CustomTypeFactory at https://doc-api.photonengine.com/en/cpp/current/a04874.html.
pathToPhotonClientSDK\Demos\demo_typeSupport contains the class SampleCustomType as an example implementation of a custom type.
Another approach would be a union: