Photon——Cached Events 缓存事件

 

Cached Events 缓存事件

     Usually, the operation   RaiseEvent  sends your event to anyone else, currently in the same room. Cached events are … cached … and will be sent to joining (new) players when they arrive.
     通常,操作 RaiseEvent 发送你的事件到其他当前游戏房间中的玩家,缓存事件是被缓存的,将被发送给新加入的玩家。
 
     Use case: Position updates are sent 10 times a second, so joining players will get your position quickly. Your player’s nickname, color and clothing don’t need ten updates per second. Once sent, it would be nice to “remember” and update new players when they arrive. This is what cached events do.
     用例:位置更新是每秒发送10次,所以加入的玩家会很快获得你的位置。你的昵称、颜色、衣服不需要每秒更新10次。一旦发送,它很高兴的记住和更新新的玩家,这是缓存事件做的事情。
 
     Cached events can be modified and removed as needed. Also, they are sorted for delivery. See below.
     当需要的时候,缓存事件可以被修改和删除,他们是被排序的。

     Disclaimer 免责声明

     Cached events are a feature of the Lite Application and Lite Lobby Application of Photon 3. They are not supported by the MMO Application or if you start from scratch.
     缓存事件是Lite和Lobby的特性,他们不被MMO和你自己开发的应用所支持。

Cache control 缓存控制

     Events are cached per actor and per event code. This way, every player can send event   “MyProfile”  (a.k.a. (byte)0) and set some values.
     事件被缓存为每个玩家和每个事件代码,每一个玩家都可以发送事件  “MyProfile”和设置一些值。
 
     Per event, the cache can be updated and replaced or simply removed.
     每个事件,这缓存可以被更新和替换或者移除。
 
     Updating an event is done by merging new content into the previously cached one. The newer event’s data hashtable will update (key by key) any existing value.
     更新一个事件是并入一个新的内容到缓存中,这新的事件的数据将更新现有的值。
 
     Photon 3 allows you to send Null as value in hashtables (and several other places), so to get rid of a key in a cached event: Send the same event, assign null to the key you want deleted and merge the event.
     Photon3允许你去发送Null作为一个值,发送这事件,null值将会删除已有的与Key相同的事件缓存。

Ordered Delivery 下令交付

     Cached events are sent to players when they join, which means they make up the fist few events they get inside a room.
     当玩家加入时缓存事件将被发送,这意味着,他们进入房间时将得到所有的事件
 
     New players get cached events, grouped by player, sorted by ascending actor number. This gives you all cached events of player 1 before you get other player’s events.
     新的玩家获取缓存事件,按照玩家编号排序,你将在获取他们人之前获取玩家1的所以事件缓存。
 
     Per (sending) player, cached events are ordered by ascending eventCode. No matter if event 10 was sent before event 1, if it’s coming from the cache, event 1 will precede event 10 (and 2 and so on).
     每个玩家,事件缓存是按照事件代码排序的。无论事件10是否是在事件1之前发送的,事件1都将排在事件10的前面。
 
     This should give you all control about the order you need. You can even cache stuff like “map” or “match rules” this way: put them in the event with lowest number and new players know this first.
     这将给你所有你需要的控制命令,你甚至可以缓存的地图、匹配规则,把它们放在事件中,新的玩家就能第一时间知道。

你可能感兴趣的:(cache)