Clear event cache in channel

Options
Hi, everyone.

For a multiplayer project i am doing, i need to cache events in the room, so that events are sent to players even if they join later.

I would like to clear the event cache, so that old events that are no more needed in the room are not sent when a new player join.

The problem here is that, in some cases, multiple events that are indipendent one from the other should be sent at the same time when a new player joins, so i should not simply clear the cache and send just one event at time.

One solution i found to this is to use sequence channels : i could group the events in channel, and when i want to send a new event, i could choose a channel and remove ONLY the events in that channel, before raising a new one.

Reading documentation and examples online, the only way i found to this is the following, but it is not working :

for (byte i = 0; i < (byte) ENetworkEvent.MAX; i++)
{
PhotonNetwork.RaiseEvent(i, null, true, new RaiseEventOptions { CachingOption = EventCaching.RemoveFromRoomCache, SequenceChannel = (byte)eventType });
}

PhotonNetwork.RaiseEvent(code, message, true, new RaiseEventOptions { CachingOption = EventCaching.AddToRoomCacheGlobal, SequenceChannel = (byte)eventType });


It should just clear the events in channel, but it seems to clear the entire cache.
What am i doing wrong ?

Thanks in advance for any help

Comments

  • Hi @Nick89,

    the problem seems to be, that you iterate through each possible custom event code and remove the related event from the server's cache. Try to remove the for-loop and only remove certain cached events. You can also take a look at the Cached Events documentation page and see if this gives you further insights.
  • Nick89
    Nick89
    edited October 2018
    Options

    Hi @Nick89,

    the problem seems to be, that you iterate through each possible custom event code and remove the related event from the server's cache. Try to remove the for-loop and only remove certain cached events. You can also take a look at the Cached Events documentation page and see if this gives you further insights.

    Yes, but i need to remove only the events in a specific channel. How can i find all the events belonging to a channel ?
  • Nick89
    Options
    Up
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited October 2018
    Options
    Hi @Nick89,

    Thank you for choosing Photon!

    What you need is Cache Slice and not Sequence Channel.
    You can cache events only in the currently selected cache per room.
    Anyone can increase or change/set the cache slice index at any time.
    You can remove/purge cached events from a specific cache only.
    You can purge cached events for all slices up to a certain index.
    You could specify which slice to set when joining a room.

    This is available only in the native SDKs I think.
    This is partially available in other C# SDKs.

    It's also not documented.
    You could find more info on the forum.
  • Nick89
    Nick89
    edited November 2018
    Options
    JohnTube said:

    Hi @Nick89,

    Thank you for choosing Photon!

    What you need is Cache Slice and not Sequence Channel.
    You can cache events only in the currently selected cache per room.
    Anyone can increase or change/set the cache slice index at any time.
    You can remove/purge cached events from a specific cache only.
    You can purge cached events for all slices up to a certain index.
    You could specify which slice to set when joining a room.

    This is available only in the native SDKs I think.
    This is partially available in other C# SDKs.

    It's also not documented.
    You could find more info on the forum.

    Ok, i am trying to understand the slice logic by myself.

    Just to figure out if i understood correctly :
    1)SliceSetIndex : does the "index" refer to eventContent parameter in PhotonNetwork.RaiseEvent ?
    2)SlicePurgeIndex : does it removes all the events in specified index ?

    Also, the documentation says that you need to set CacheSliceIndex in RaiseEventOptions class, but i could not find it as member of the class !
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    1) Yes. there should be a RaiseEventOptions.CacheSliceIndex. but it's not there now in the C#/.NET SDKs
    2) Yes.

    Also, the documentation says that you need to set CacheSliceIndex in RaiseEventOptions class, but i could not find it as member of the class !
    If you need this, send an email to developer@photonengine.com requesting it.