RaiseEvent Problem

Options
New to photon networking I am using raise events for my board game. Sometimes event won't fire, but most of the time they work fine need help ...
private void OnEnable() {

PhotonNetwork.NetworkingClient.EventReceived += NetworkingClient_EventReceived;

}

private void Disable() {

   PhotonNetwork.NetworkingClient.EventReceived -= NetworkingClient_EventReceived;
}
private void NetworkingClient_EventReceived(EventData obj) {

    byte eventCode = obj.Code;

    if (eventCode == (byte)EnumGame.DiceRoll)
    {

        EventManager.instance.rolldiceEvent(obj);
    }

    if (eventCode == (byte)EnumGame.DiceNumber)
    {

        EventManager.instance.displaydiceNumber(obj);
    }

    if (eventCode == (byte)EnumGame.Passdice)
    {

        EventManager.instance.passdicetootherPlayer(obj);


    }


    if (eventCode == (byte)EnumGame.PassTurn)
    {

        EventManager.instance.passturntootherPlayer(obj);
    

    }

}

This is how i use to raise event in my script i am not getting any kind of exception
object[] data = new object[] { Photonplayer.instance.getplayerId() };
    RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.Others };
    PhotonNetwork.RaiseEvent((byte)EnumGame.Passdice, data, raiseEventOptions, SendOptions.SendUnreliable);

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Toseef,

    Maybe the event sometimes arrive before OnEnable and thus the callback is not triggered?
    Try subscribing earlier in Awake maybe and unsubscribing in OnDestroy?
    Or making sure the callbacks class is present before the event us supposed to arrive, like before joining the room?
  • Toseef
    Options
    @JohnTube i figured it out i was sending events unreliably now i have changed it to send relabel problem solved