How to get opRaiseEvent to start working?

I've come across an issue with receiving custom events.

Currently, I am trying to send a JString as that is supposed to be one of the supported types for serialization. While testing if it worked, it seemed that the listener was never getting the 'customEventAction' called. Most likely meaning that nothing was received. But I am unsure why nothing would be received. I tried using a hashtable like the one in the Demo file, but nothing was received either.


Best Answer

  • Kaiserludi
    Kaiserludi admin
    Answer ✓

    Hi @StereoJunkie.


    If you want to send a JString, then use ValueObject<JString>. ValueObject<JString*>means an array of JString instances. Hence the information that the dimension is '1', is correct. A JString has 0 dimensions (as it is not an array), a JString* has 1 dimension, a JString** 2 dimensions, and so on.

    What are you trying to achieve?


    Does it have to do with the reliable bool in the opRaiseEvent parameters?

    No. The reliable flag determines if a message will get repeated in case that it should not be received in case it's lost on it's way over the network. It does not affect the payload of the message.

Answers

  • Hi @StereoJunkie.


    Which of the demo projects are you referring to?


    opRaiseEvent() on default sends events to everyone else inside the same room except for the sender. Most of the demos use this default setting and hence require that you run at least 2 clients or otherwise there is no one to receive the events.


    If the intended receivers differ from this default, then you need to explicitly specify this in the RaiseEventOptions.


    You can set the 'receiverGroup' option to ReceiverGroup::ALL to include the sender itself in the list of receivers as well or you can set the 'targetPlayers' option to the player number of the local player to only send the message to the sender and not to anyone else, like demo_basics does.


    "Currently, I am trying to send a JString as that is supposed to be one of the supported types for serialization."

    It is indeed one of the supported types. For comparison you can attempt to send a type of which you know for sure that it isn't supported and you will see that doing so will result in a compile error as the API already catches unsupported types at compile time.

    So if your code compiles, then the type of the supplied data should be fine and the reason for the missing customEventAction() call must lay somewhere else.

  • That seems to have fixed not receiving my own events but now I have an issue where ValueObject<JString*> seems to sometimes detect that the eventContent has type 's' (which is correct) but dimension '1' which I am pretty sure is supposed to be 0. This causes my program to crash naturally but I don't understand why the dimension would change sometimes. Does it have to do with the reliable bool in the opRaiseEvent parameters?

  • Kaiserludi
    Kaiserludi admin
    Answer ✓

    Hi @StereoJunkie.


    If you want to send a JString, then use ValueObject<JString>. ValueObject<JString*>means an array of JString instances. Hence the information that the dimension is '1', is correct. A JString has 0 dimensions (as it is not an array), a JString* has 1 dimension, a JString** 2 dimensions, and so on.

    What are you trying to achieve?


    Does it have to do with the reliable bool in the opRaiseEvent parameters?

    No. The reliable flag determines if a message will get repeated in case that it should not be received in case it's lost on it's way over the network. It does not affect the payload of the message.

  • Currently a group of student (me included) are working on a prototype for virtual conferencing in a 3D environment. Now I am just trying to figure out the Photon SDK and plan on building a wrapper for it to make it work easily in Unreal Engine.

  • Kaiserludi
    Kaiserludi admin
    edited October 2021

    When I wrote "What are you trying to achieve?", I meant what you were trying to achieve when you attempted to send a ValueObject<JString*>, but apparently did not attempt to send an array (as you did not expect the dimension to be 1).

    Sending a pointer to an arbitrary location in memory over the network does not really make sense, as the remote client can't access the local clients memory. So you actually have to send the content of the memory to which the pointer points to. So if your JString* points to a single JString, then you need to dereference it and pass *pointerToJString and not pointerToJString to opRaiseEvent(). If your JString* points to the first element in an array of JString, then you need to pass the pointer, but to also pass the element count of the array (opRaiseEvent() has an overload that accepts this element count as a separate parameter).


    and plan on building a wrapper for it to make it work easily in Unreal Engine.

    Would you care to elaborate? How would your wrapper make Photon easier to use with Unreal? Do you plan to provide blueprints APIs for Photon? If not, then how would your wrapper be easier to use from Unreal than the existing APIs?


    Also, are you aware of this Unreal asset for Photon: https://www.unrealengine.com/marketplace/en-US/product/photon-cloud-api-by-xixgames?

    This might already provide everything that you are trying to achieve with your planned wrapper.

    It's creator @juaxix is present in this forum as well.

  • Yeah I know about the Unreal asset. It's unfortunate that the only nice wrapper is locked behind a pay-wall. That is the whole reason we are making something more useable for other people. Including video documentation about the SDK itself.

    Also yes, the wrapper will provide blueprint APIs for photon that are intended to be used by people who don't have prior networking experience.