https://www.cnblogs.com/zihunqingxin/p/4755168.html
https://blog.csdn.net/busai2/article/details/82503699
https://www.jb51.net/article/146063.htm
func (self *Observe) start() {
if self == nil || self.roomid <= 0 {
return
}
antnet.Go2(func(cstop chan struct{}) {
obMgr.Store(self.roomid, self)
defer obMgr.Delete(self.roomid)
if !self.sendStart() {
return
}
ticker := time.NewTicker(time.Second * 1)
timeout := time.After(time.Hour * 1)
sendbuf := bytes.NewBuffer(make([]byte, 1024*16))
defer func() {
ticker.Stop()
self.Over()
self.sendFrame(sendbuf)
self.sendOver()
}()
for {
select {
case <-cstop:
return
case <-self.over:
return
case <-ticker.C:
if !self.sendFrame(sendbuf) {
return
}
case <-timeout:
antnet.LogWarn("ob room:%d is too long", self.roomid)
return
}
}
})
}