Event/RPC Sequence

Options
Hello!
Apologies if this has been asked before - couldn't find anything. I'm using manual instantiation via Events and running into an issue where my RPCs are being received before my Event. Hopefully this demonstrates the problem,

'Sender':
- Raises event with instantiation/ photonView data.
- Other components also send any additional 'initialisation' data via RPC after this event was sent.
- Other components also start sending OnSerialization.

'Receiver':
- Receives RPC calls. Can't handle them since we haven't set up the object.
- Receives OnSerialization for viewIDs it doesn't have.
- Receives event, sets up the object.
- Future OnSerialization calls work fine.

I incorrectly assumed that these events/ rpcs would be sent and received in a sequence. So I'm wondering what would be your recommended way of handling this?

Personally I'd rather have the RPC calls be cached until the events have been handled, this seems like the option that creates the least extra data to be sent across.
Another option is to send any additional initialisation data along with the event. Kinda difficult to do nicely since there could be any number of components with additional data.
Last option I could think of is having the 'receiver' send a message back to the 'sender' saying "hey im ready to receive stuff now" and then send all the initialisation data. Creates a bunch of delay and overhead but quite simple.

Any input would be appreciated!

Comments

  • myleslambert
    Options
    If anyone else runs into this issue, I ended up sending the initialisation data along with the event. It bloated the message a bit but wasn't too much work to implement.
  • Hmm I still have cases where this is a problem - such as when an RPC is called a few frames after instantiation. Could I get some input on this from the devs?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @myleslambert,

    Thank you for choosing Photon!

    PUN RPC is RaiseEvent call internally.
    RaiseEvent requests and resulting custom events are sent in order/sequence by default.

    Maybe you are using a different RaiseEventOption.SequenceChannel? if you change sequence channels, events may be received not in the same order as some sequence channels have priority over others.
    PUN RPC are sent reliable, maybe you need to send all events reliable to keep order.

    Sending custom init data in instantiation call is a good call.
  • Thanks John!
    You're right, I wasn't digging into this issue properly - the Photon side of things was fine, the issue was I was waiting for some resources to load before assigning the ViewId.
    Apologies and thanks for the help :)