You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

29 lines
681 B

package event
import (
"fmt"
"texas-poker-bk/internal/logic/delayer"
"texas-poker-bk/internal/logic/store"
"texas-poker-bk/tool/watcher"
"time"
)
var (
// OfflineWatcher 离线动作
OfflineWatcher *watcher.Watcher[int64, bool]
)
func init() {
OfflineWatcher = watcher.NewWatcher(128, handleOffline)
go OfflineWatcher.Run()
}
func handleOffline(e *watcher.Event[int64, bool]) {
account := store.NetAccounts.Get(e.Publisher)
if account == nil {
return
}
fmt.Printf("account %d, %s handle offline.\n", account.Id, account.UserName)
// 10s内未重连上处理离线逻辑
account.OfflineDelayCanceler = delayer.OfflineDelayer.Delay(10*time.Second, account.Id)
}