feat: lockstep 支持获取帧同步客户端数量

This commit is contained in:
kercylan98 2023-11-01 18:13:50 +08:00
parent f475aac387
commit 589a424491
1 changed files with 7 additions and 0 deletions

View File

@ -87,6 +87,13 @@ func (slf *Lockstep[ClientID, Command]) JoinClientWithFrame(client Client[Client
}
// GetClientCount 获取客户端数量
func (slf *Lockstep[ClientID, Command]) GetClientCount() int {
slf.clientLock.RLock()
defer slf.clientLock.RUnlock()
return len(slf.clients)
}
// DropCache 丢弃特定帧的缓存,当 handler 返回 true 时将丢弃缓存
func (slf *Lockstep[ClientID, Command]) DropCache(handler func(frame int64) bool) {
slf.frameCacheLock.Lock()