Control order of IPunObservable.OnPhotonSerializeView and IOnEventCallback.OnEvent?

Options
Is it possible to control the order of invocation of these two events?

My goal is to have values be synchronized, and events invoked after these values have changed.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @SINe,

    Thank you for choosing Photon!

    We don't understand the use case.
    The order of the invocation can't be really decided as Unity has its own execution order of scripts.

    IPunObservable.OnPhotonSerializeView is actually a callback for an event.
    So you may get the event inside IOnEventCallback.OnEvent.
    The codes for PhotonSerializeView events are either 201 or 206.
  • SINe
    Options
    My use case, generally, is "modification of serialized data should be preserved in the order of events."

    Specifically, I am
    - changing some values which are sent via PhotonSerializeView event
    - raising a custom event
    Intuitively, I would want the PhotonSerializeView event to occur before custom event

    Here's some code snippets, to help illustrate my issue.
    HandSystem.OnTriggerEnter
          entity.HandWagerComponent.CoinEntityID = coinEntityID;
          entity.HandWagerComponent.WagerRole = wagerRole;
          entity.HandWagerComponent.IsReady = false;
          
          this.onWagerEntered_raise(playerActorNumber, coinEntityID, wagerRole); // wrapper around PhotonNetwork.RaiseEvent, for a OnWagerEntered event
    HandWagerComponent.OnPhotonSerializeView
            stream
              .Recieve(out this.CoinEntityID)
              .Recieve(out this.WagerRole)
              .Recieve(out this.IsReady);


    After doing some digging into the source I've determined this cannot be resolved by changing script execution order (please correct me if I'm wrong). This is because PhotonHandler.LateUpdate invokes OnSerializeView for all PhotonView, then immediately sends outgoing events. Regardless of script execution order, PhotonSerializeView are always sent last.


    Possible solutions would then be
    A: manually raise the PhotonSerializeView event any time I change the data
    B: sort outgoing events before they are sent (based on event code, ideally)

    Are either of these possible with PUN out of the box?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @SINe,

    Can you replace the PhotonSerializeView with custom RaiseEvent to set variables?
    Can you delay calling RaiseEvent 'until' LateUpdate and send outgoing commands right away?
    Maybe add a condition in the custom event data to check the value of the view variables? Maybe even replace those with custom room properties?
  • SINe
    SINe
    edited April 2019
    Options
    Calling RaiseEvent in LateUpdate after PhotonHandler.LateUpdate would have worked, but I managed to resolve my via option A.

    What is PUN licensed under? I cannot find any information regarding that. I'm worried releasing my game with these modifications to the source code (even in binary form) would violate the PUN license.

    EDIT:
    I found here: https://dashboard.photonengine.com/en/Account/LicenseTerms
    "Customer agrees not to ... (d) create modifications to or derivative works of the Licensed Software;"

    But then I found here: https://doc-api.photonengine.com/en/pun/v2/index.html
    "Full source code is available, so you can scale this package to support any type of multiplayer game you come up with."

    Am I allowed to release a game with modifications to PUN source code?