1
This commit is contained in:
parent
835a0e2fad
commit
5c223abe77
@ -16,12 +16,14 @@ type player struct {
|
||||
accountId string
|
||||
sessionId string
|
||||
battling bool
|
||||
lastRefreshCacheTime int64
|
||||
}
|
||||
|
||||
func (this *player) init(req *pendingLoginRequest, rspObj *common.LoginRsp){
|
||||
this.socket = req.hdr.GetSocket()
|
||||
this.accountId = req.msg.GetAccountId()
|
||||
this.sessionId = req.msg.GetSessionId()
|
||||
this.refreshCache()
|
||||
}
|
||||
|
||||
func (this *player) GetAccountId() string {
|
||||
@ -51,6 +53,7 @@ func (this *player) reBind(socket f5.WspCliConn, sessionId string) {
|
||||
this.socket = socket
|
||||
this.sessionId = sessionId
|
||||
_playerMgr.socketHash[this.socket] = this
|
||||
this.refreshCache()
|
||||
}
|
||||
|
||||
func (this *player) CMPing(hdr *f5.MsgHdr, msg *cs.CMPing) {
|
||||
@ -866,6 +869,19 @@ func (this *player) onOffline() {
|
||||
f5.GetSysLog().Info("onOffline %s", this.GetAccountId())
|
||||
}
|
||||
|
||||
func (this *player) refreshCache() {
|
||||
if f5.GetApp().GetNowSeconds() - this.lastRefreshCacheTime > 5 {
|
||||
this.lastRefreshCacheTime = f5.GetApp().GetNowSeconds()
|
||||
f5.GetTimer().SetTimeout(
|
||||
1000 * 5,
|
||||
func(e int32, args *q5.Args) {
|
||||
if e == q5.TIMER_EXEC_EVENT {
|
||||
GetCacheMgr().PreLoadUsers([]string{this.GetAccountId()})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func newPlayer() *player {
|
||||
p := new(player)
|
||||
return p
|
||||
|
Loading…
x
Reference in New Issue
Block a user