1
This commit is contained in:
parent
1b9e9459e1
commit
e1e1596ac6
@ -29,7 +29,7 @@ type App interface {
|
||||
}
|
||||
|
||||
type Player interface {
|
||||
Lock()
|
||||
Lock() bool
|
||||
UnLock()
|
||||
GetAccountId() string
|
||||
GetRegisterTime() int32
|
||||
|
@ -3,6 +3,7 @@ package middleware
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
. "main/global"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func CaAuth(c *gin.Context) {
|
||||
@ -12,7 +13,14 @@ func CaAuth(c *gin.Context) {
|
||||
if hum == nil {
|
||||
hum = GetPlayerMgr().ForceCreatePlayer(accountId, sessionId)
|
||||
}
|
||||
hum.Lock()
|
||||
if !hum.Lock() {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errcode": 500,
|
||||
"errmsg": "server internal error",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
c.Set("hum", hum)
|
||||
c.Next()
|
||||
hum.UnLock()
|
||||
|
@ -28,11 +28,16 @@ func (this *player) init() {
|
||||
this.inboxHash = make(map[int64]*inbox)
|
||||
}
|
||||
|
||||
func (this *player) Lock() {
|
||||
func (this *player) Lock() bool {
|
||||
this.lock.Lock()
|
||||
if !this.loaded {
|
||||
this.load()
|
||||
}
|
||||
ok := this.loaded
|
||||
if !ok {
|
||||
this.UnLock()
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
||||
func (this *player) UnLock() {
|
||||
@ -112,10 +117,10 @@ func (this *player) checkLock() {
|
||||
func (this *player) load() {
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.MAIL_DB,
|
||||
"SELECT * FROM t_inbox WHERE account_id=? AND expiretime>?",
|
||||
"SELECT * FROM t_inbox WHERE account_id=? AND expiretime<?",
|
||||
[]string{
|
||||
this.GetAccountId(),
|
||||
q5.ToString(f5.GetApp().GetNowSeconds() - 3600 * 24 * 1),
|
||||
q5.ToString(f5.GetApp().GetRealSeconds() + 3600 * 24 * 7),
|
||||
},
|
||||
func (err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user