'RaiseEvent seems to not execute properly
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);
Solution 1:[1]
object[] data = new object[] { Photonplayer.instance.getplayerId() };
RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.Others };
PhotonNetwork.RaiseEvent((byte)EnumGame.Passdice, data, raiseEventOptions, SendOptions.SendReliable);
Change "SendOptions.SendUnreliable" to "SendOptions.SendReliable" in RaiseEvent's 4th parameter.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | krnitheesh16 |
