This commit is contained in:
aozhiwei 2024-04-20 15:57:46 +08:00
parent a090e3136e
commit 782e8ccb84
4 changed files with 32 additions and 2 deletions

View File

@ -35,6 +35,18 @@ type LoginRsp struct {
} `json:"info"`
}
type UserQueryStatusRsp struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
Users []*UserStatus
}
type UserStatus struct {
AccountId string `json:"account_id"`
Battling int32 `json:"battling"`
Online int32 `json:"online"`
}
type WspListener interface {
ProcessSSMMsg(*ss.SsNetMsgHandler, *f5.MsgHdr)
SendProxyMsg(net.Conn, uint16, proto.Message)

View File

@ -11,6 +11,8 @@ import (
"main/constant"
"main/common"
"math/rand"
"strings"
"net/http"
"github.com/gin-gonic/gin"
. "main/global"
)
@ -78,7 +80,22 @@ func (this *playerMgr) UnInit() {
}
func (this *playerMgr) queryStatusHandle(c *gin.Context) {
accountIds := strings.Split(c.DefaultQuery("accountIds", ""), ",")
rspObj := new(common.UserQueryStatusRsp)
f5.GetApp().RegisterMainThreadCb(
func () {
for _, accountId := range(accountIds) {
hum := _playerMgr.GetPlayerByAccountId(accountId)
if hum != nil {
u := new(common.UserStatus)
u.AccountId = accountId
u.Battling = q5.BoolToInt32(hum.IsBattling())
u.Online = q5.BoolToInt32(hum.IsOnline())
q5.AppendSlice(&rspObj.Users, u)
c.JSON(http.StatusOK, rspObj)
}
}
})
}
func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {

View File

@ -77,6 +77,7 @@ type UserQueryStatusRsp struct {
Users []struct {
AccountId string `json:"account_id"`
Battling int32 `json:"battling"`
Online int32 `json:"online"`
}
}

2
third_party/q5 vendored

@ -1 +1 @@
Subproject commit fc08e4f8c51900b8eec8f67e29ccd321c1f1a758
Subproject commit 75b0c72d7201725700b1d8d383fd36a63c81aebe