https://studygolang.com/articles/3557
func (self *Observe) Frame(frameIdx int, frames map[int]*PVPFrame) {
if self == nil || self.roomid <= 0 {
return
}
if !self.IsRunning() {
return
}
if !self.HasWatcher() {
return
}
recvmax := atomic.LoadInt32(&self.lastrecv)
if int32(frameIdx) <= recvmax {
return
}
for idx := recvmax + 1; idx <= int32(frameIdx); idx++ {
frame, ok := frames[int(idx)]
if !ok {
continue
}
self.frames.Store(idx, frame)
}
atomic.StoreInt32(&self.lastrecv, int32(frameIdx))
}