Cache only the last event, that is sent with PhotonNetwork.RaiseEvent, on the server

In my new game I use events to synchronize the game state between players. The state of a player can be encoded compact in only 1 event. That is why I send every time the whole state of the player.
When a new player joins the room, the easiest way to synchronize the other players with him is to send him the last event of every other player. I thought I can do this with event caching on the server side. The idea is to cache on the server only the last event sent and then send it automatically to the new joined players.

In other words, I want to replace the cached event every time on the server, but I saw that EventCaching.ReplaceCache is obsolete now! Is there an alternative to cache only the last event on the server?

If I use EventCaching.AddToRoomCache all events are cached and then send to the new player -> bad.
I also don't want to send an extra delete event every time. My game should support up to 20 player and already operates close to the 500 msg/sec per room limit.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2017
    Hi @kampfhund,

    Thank you for choosing Photon!

    You already enumerated all the things you could do and rejected them.
    Now maybe you can change the behavior a bit and instead of relying on the server to resend a cached event, do this from clients instead:

    Each client caches the last event locally and when a new join event is received, resend the cached event to the late joiner only.
  • kampfhund
    kampfhund
    edited September 2017
    @JohnTube that was my backup plan, but I thought that there is an easier way through the server...
    I will then cache on the client side and use interest groups to filter the far away players and further reduce the message count...
  • @JohnTube I implemented the player side caching and also added network culling, but unfortunately I lost lots of time with the following problem: When PhotonNetwork.SetInterestGroups is called with both parameter equal to byte[0] the game freezes (or if it is run in Unity editor, then the whole editor freezes). Is this expected behavior or is it a bug? I'm using the latest pun plugin: 1.86.1
  • JohnTube
    JohnTube ✭✭✭✭✭
    I will test this but can you tell me why do you set both groups to byte[0], it means that you want to add all groups and remove all groups at the same time. Adding should be the result though as it has the priority.
    You should fix the call and change the values. I will test it nevertheless.
  • I calculate the new groups on the fly and remove the old groups . It was a bug on my side, that on some specific situations there were no groups found -> byte[0].