更新本服在线用户

This commit is contained in:
wh_zcy 2022-08-18 11:30:15 +08:00
parent 6d844a192f
commit 85c0fc0b72
6 changed files with 29 additions and 15 deletions

View File

@ -63,6 +63,7 @@ var (
ff(comm.ModuleFriend, friend.FriendSubTypeDelBlack): &formview.FriendDelblackView{}, ff(comm.ModuleFriend, friend.FriendSubTypeDelBlack): &formview.FriendDelblackView{},
ff(comm.ModuleFriend, friend.FriendSubTypeSearch): &formview.FriendSearchView{}, ff(comm.ModuleFriend, friend.FriendSubTypeSearch): &formview.FriendSearchView{},
ff(comm.ModuleFriend, friend.FriendSubTypeZanList): &formview.FriendZanView{}, ff(comm.ModuleFriend, friend.FriendSubTypeZanList): &formview.FriendZanView{},
ff(comm.ModuleFriend, friend.FriendSubTypeRandList): &formview.FriendRandListView{},
// shop // shop
ff(comm.ModuleShop, "getlist"): &formview.ShopListView{}, ff(comm.ModuleShop, "getlist"): &formview.ShopListView{},
ff(comm.ModuleShop, "buy"): &formview.ShopBuyView{}, ff(comm.ModuleShop, "buy"): &formview.ShopBuyView{},
@ -132,6 +133,7 @@ var (
ff(comm.ModuleFriend, friend.FriendSubTypeDelBlack), ff(comm.ModuleFriend, friend.FriendSubTypeDelBlack),
ff(comm.ModuleFriend, friend.FriendSubTypeSearch), ff(comm.ModuleFriend, friend.FriendSubTypeSearch),
ff(comm.ModuleFriend, friend.FriendSubTypeZanList), ff(comm.ModuleFriend, friend.FriendSubTypeZanList),
ff(comm.ModuleFriend, friend.FriendSubTypeRandList),
}, },
"shop": { "shop": {
ff(comm.ModuleShop, "getlist"), ff(comm.ModuleShop, "getlist"),
@ -365,6 +367,13 @@ var (
MainType: string(comm.ModuleFriend), MainType: string(comm.ModuleFriend),
Enabled: true, Enabled: true,
}, },
ff(comm.ModuleFriend, friend.FriendSubTypeRandList): {
NavLabel: "在线玩家",
Desc: "在线玩家列表",
MainType: string(comm.ModuleFriend),
SubType: friend.FriendSubTypeRandList,
Enabled: true,
},
ff(comm.ModuleFriend, friend.FriendSubTypeList): { ff(comm.ModuleFriend, friend.FriendSubTypeList): {
NavLabel: "好友列表", NavLabel: "好友列表",
Desc: "好友列表", Desc: "好友列表",

View File

@ -20,6 +20,10 @@ const (
Service_Mainte = "mainte" Service_Mainte = "mainte"
) )
const (
RDS_SESSION = "online"
)
//ERR //ERR
const ( const (
MainTypeNotify = "notify" //通知 MainTypeNotify = "notify" //通知

View File

@ -74,6 +74,8 @@ type (
GetUserExpand(uid string) (result *pb.DBUserExpand, err error) GetUserExpand(uid string) (result *pb.DBUserExpand, err error)
//更新用户expand //更新用户expand
ChangeUserExpand(uid string, value map[string]interface{}) error ChangeUserExpand(uid string, value map[string]interface{}) error
// 本服在线玩家列表
UserOnlineList() ([]*pb.CacheUser, error)
} }
//武器模块 //武器模块
IEquipment interface { IEquipment interface {

View File

@ -80,7 +80,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
} }
//缓存user session //缓存user session
err = this.module.modelSession.AddList("online", user.Uid, map[string]interface{}{ err = this.module.modelSession.AddList(comm.RDS_SESSION, user.Uid, map[string]interface{}{
"uid": user.Uid, "uid": user.Uid,
"sessionId": session.GetSessionId(), "sessionId": session.GetSessionId(),
"serviceTag": session.GetServiecTag(), "serviceTag": session.GetServiecTag(),

View File

@ -3,6 +3,7 @@ package user
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
) )
@ -20,18 +21,11 @@ func (this *ModelSession) Init(service core.IService, module core.IModule, comp
} }
//获取用户 //获取用户
func (this *ModelSession) getUserSession(uid string) (cuser *pb.CacheUser) { func (this *ModelSession) getUserSession(uid string) (user *pb.CacheUser) {
var sl []*pb.CacheUser user = &pb.CacheUser{}
if err := this.GetListObj(comm.RDS_SESSION, uid, user); err != nil {
if err := this.GetList("online", sl); err != nil { log.Errorf("getUserSession err:%v", err)
this.module.Errorf("GetUserSession err:%v", err) return nil
return
} }
return user
for _, v := range sl {
if v.Uid == uid {
return v
}
}
return
} }

View File

@ -76,7 +76,12 @@ func (this *User) CleanSession(session comm.IUserSession) {
} }
// 在线玩家列表 // 在线玩家列表
func (this *User) UserOnline() { func (this *User) UserOnlineList() ([]*pb.CacheUser, error) {
var cache []*pb.CacheUser
if err := this.modelSession.GetList(comm.RDS_SESSION, &cache); err != nil {
return nil, err
}
return cache, nil
} }
//查询用户属性值 例如 金币 经验 //查询用户属性值 例如 金币 经验