The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Clear event cache in channel

Nick89
2018-10-18 13:59:49

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 });
}

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

[Deleted User]
2018-10-18 15:09:07

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
2018-10-18 15:31:53

@Christian_Simon wrote:

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
2018-10-23 08:33:55

Up

JohnTube
2018-10-29 13:59:52

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
2018-11-12 15:04:01

@JohnTube wrote:

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
2018-11-13 09:24:50

  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 [email protected] requesting it. Back to top