diff --git a/modules/friend/api_applylist.go b/modules/friend/api_applylist.go index 503e0ab48..443576914 100644 --- a/modules/friend/api_applylist.go +++ b/modules/friend/api_applylist.go @@ -45,6 +45,8 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyLis list = append(list, &pb.FriendBase{ UserId: userId, NickName: user.Name, + Level: user.Lv, + Avatar: user.Avatar, }) } diff --git a/modules/friend/api_list.go b/modules/friend/api_list.go index 264d1d36e..0a10684ef 100644 --- a/modules/friend/api_list.go +++ b/modules/friend/api_list.go @@ -44,6 +44,8 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (cod list = append(list, &pb.FriendBase{ UserId: userId, NickName: user.Name, + Level: user.Lv, + Avatar: user.Avatar, }) } diff --git a/modules/friend/api_randlist.go b/modules/friend/api_randlist.go new file mode 100644 index 000000000..0a65574cc --- /dev/null +++ b/modules/friend/api_randlist.go @@ -0,0 +1,33 @@ +package friend + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" +) + +func (this *apiComp) RandlistCheck(session comm.IUserSession, req *pb.FriendOnlineReq) (code pb.ErrorCode) { + return +} + +func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendOnlineReq) (code pb.ErrorCode, data proto.Message) { + var ( + self *pb.DBFriend + ) + //在线玩家 + + self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId()) + if self == nil { + code = pb.ErrorCode_FriendSelfNoData + return + } + + // 好友列表 + // self.FriendIds + + // 已申请的好友 + // self.ApplyIds + + return +} diff --git a/modules/user/api_login.go b/modules/user/api_login.go index dcbacee7b..9c7425142 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -80,7 +80,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod } //缓存user session - err = this.module.modelSession.Change(user.Uid, map[string]interface{}{ + err = this.module.modelSession.ChangeList("online", user.Uid, map[string]interface{}{ "uid": user.Uid, "sessionId": session.GetSessionId(), "serviceTag": session.GetServiecTag(), diff --git a/modules/user/model_session.go b/modules/user/model_session.go index b417f1b3f..040928571 100644 --- a/modules/user/model_session.go +++ b/modules/user/model_session.go @@ -21,10 +21,17 @@ func (this *ModelSession) Init(service core.IService, module core.IModule, comp //获取用户 func (this *ModelSession) getUserSession(uid string) (cuser *pb.CacheUser) { - cuser = &pb.CacheUser{} - if err := this.Get(uid, cuser); err != nil { + var sl []*pb.CacheUser + + if err := this.GetList("online", sl); err != nil { this.module.Errorf("GetUserSession err:%v", err) return } + + for _, v := range sl { + if v.Uid == uid { + return v + } + } return } diff --git a/modules/user/module.go b/modules/user/module.go index 2ae4b0316..63f5a405b 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -75,6 +75,10 @@ func (this *User) CleanSession(session comm.IUserSession) { this.modelSetting.Del(session.GetUserId(), db.SetDBMgoLog(false)) } +// 在线玩家列表 +func (this *User) UserOnline() { +} + //查询用户属性值 例如 金币 经验 func (this *User) QueryAttributeValue(uid string, attr string) (value int32) { user := this.modelUser.GetUser(uid)