From 782e8ccb841c2c613e7b1202816bf29efc301f1c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 20 Apr 2024 15:57:46 +0800 Subject: [PATCH] 1 --- server/imserver/common/types.go | 12 ++++++++++++ server/imserver/player/playermgr.go | 19 ++++++++++++++++++- server/matchserver/common/types.go | 1 + third_party/q5 | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/server/imserver/common/types.go b/server/imserver/common/types.go index 7b98e92c..f6fa6d4e 100644 --- a/server/imserver/common/types.go +++ b/server/imserver/common/types.go @@ -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) diff --git a/server/imserver/player/playermgr.go b/server/imserver/player/playermgr.go index 27c5b91a..6e870b42 100644 --- a/server/imserver/player/playermgr.go +++ b/server/imserver/player/playermgr.go @@ -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) { diff --git a/server/matchserver/common/types.go b/server/matchserver/common/types.go index 053682a7..785bb771 100644 --- a/server/matchserver/common/types.go +++ b/server/matchserver/common/types.go @@ -77,6 +77,7 @@ type UserQueryStatusRsp struct { Users []struct { AccountId string `json:"account_id"` Battling int32 `json:"battling"` + Online int32 `json:"online"` } } diff --git a/third_party/q5 b/third_party/q5 index fc08e4f8..75b0c72d 160000 --- a/third_party/q5 +++ b/third_party/q5 @@ -1 +1 @@ -Subproject commit fc08e4f8c51900b8eec8f67e29ccd321c1f1a758 +Subproject commit 75b0c72d7201725700b1d8d383fd36a63c81aebe