package friend import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "go_dreamfactory/utils" "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 ) //在线玩家 cu, err := this.moduleFriend.ModuleUser.UserOnlineList() if err != nil { code = pb.ErrorCode_DBError return } self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId()) if self == nil { code = pb.ErrorCode_FriendSelfNoData return } var userList []*pb.FriendBase for _, v := range cu { if v.Uid == session.GetUserId() { continue } if _, ok := utils.Findx(self.FriendIds, v.Uid); ok { continue } if _, ok := utils.Findx(self.ApplyIds, v.Uid); ok { continue } user := this.moduleFriend.ModuleUser.GetUser(v.Uid) if user == nil { continue } userList = append(userList, &pb.FriendBase{ UserId: user.Uid, NickName: user.Name, Level: user.Lv, }) } rsp := &pb.FriendOnlineResp{ List: userList, } if err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeRandList, rsp); err != nil { code = pb.ErrorCode_SystemError return } return }