[Solved] PhotonServer Eventflow Problem
Options
I am implementing my own event handling logic with a self-hosted server, since my authoritative game design has to go a bit beyond what Lite and LiteLobby have to offer. I am using Playmaker on the Unity-side and I want to catch all events in one place.
I fire a request in my Playmaker action. The request reaches the server just fine.
On the server I work with the operationRequest, modify it and then send a response to the targeted client. This also works.
The client is then supposed to catch the incoming event in a static class that distributes those events:
Sadly all I get is a fatal error when the event reaches the client.
So what am I doing wrong? :-) Any hints are appreciated.
I fire a request in my Playmaker action. The request reaches the server just fine.
PhotonNetwork.networkingPeer.OpCustom(0, PhotonPackage, true);
On the server I work with the operationRequest, modify it and then send a response to the targeted client. This also works.
EventData response = new EventData(0, request); peer.SendEvent(response, parameters); peer.Flush();
The client is then supposed to catch the incoming event in a static class that distributes those events:
public static class PhotonManager { static PhotonManager() { PhotonNetwork.OnEventCall += ReceiveEvent; } private static void ReceiveEvent(byte eventCode, object content, int senderId) { // handle event } // other stuff }
Sadly all I get is a fatal error when the event reaches the client.
Error. Unhandled event: Event 0. UnityEngine.Debug:LogError(Object) NetworkingPeer:OnEvent(EventData) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1733) ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[]) ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:76)
So what am I doing wrong? :-) Any hints are appreciated.
0
Comments
-
Okay, it was quite simple and I could have figured it out quicker.
Apparently using 0 (Zero) as EventCode is a bad idea, because only the EventCodes 1-199 will be forwarded to OnEventCall.
I thought everything below 200 was fine and so my enums defining the EventCodes started at 0. :-)
Thanks anyway. Awesome Product!0 -
Oh. Sorry you ran into this! I'm glad you could find it relatively quick.
I am not sure why I only do the callback for event 1..199. I'll check things and make it more clear which codes can be used.0 -
Not a problem. But thank you for responding anyway. I really appreciate that.0
-
I now changed the EventCallback to give you any eventCode < 200.
RaiseEvent in the client now also accepts 0..199 and logs a proper warning when an event is not acceptable and sent (but in your case, this would not have helped).
PUN 1.26 will have this change. Going to be released soon.0