Custom network events.

Options
Hello. :D

I'm using Photon PUN, and am looking for information on how to create events (not RPC) events as "OnLeftRoom", "OnDisconnectedFromPhoton", etc ...
is this possible, as I can do (create a custom event).

Thank you.

Comments

  • This has a number of the events that you may find helpful:

    http://doc-api.exitgames.com/en/realtim ... 440ebdbc88
  • Thanks for commenting.

    if either already took account of this before, but what I want is to create my own events like these (if possible).
  • vadim
    Options
    Hi,
    Send events with PhotonNetwork.RaiseEvent(...) and receive them with method registered in PhotonNetwork.OnEventCall.
    See PhotonNetwork.RaiseEvent help for details
  • sorry for the late reply and Thank you for replying.

    thank you very much @vadim is exactly what I wanted. :D

    I read the documentation, I can now just ask if I can confirm that this would be a correct way to use it, please.

    first register the event:
    void OnJoinedRoom(){
    if(PhotonNetwork.isMasterClient){
      PhotonNetwork.OnEventCall += this.OnEventRaised;
     Debug.Log(" registered new event");
    }
    }
    
    then for events I have this:
    public void OnEventRaised(byte eventID, object customInfo, int PlayerID)
        {
            Debug.Log("Recive this eventid "+eventID+"with this info "+customInfo+"from : "+PlayerID);
    if(eventID == (byte)1){ //only example
    CallmyCustomFunction(customInfo);
    }
        }
    
    I wonder if this is a correct way to use this method ...?

    to by the way, also I have a problem sending the event, and is the player who sends the event does not recive the event, how can I fix this ..?

    Thank you.
  • vadim
    Options
    You set up only master client for receiving events. Is that what you want? If so then you should send event from master too if you want receive event on sender. But it's hardly makes sense.
    Better subscribe all clients to events and target client when sending (save bandwidth). Or skip handling in OnEventRaised by condition (if non-master e.g.)