好友跨服处理
This commit is contained in:
parent
dbccb138d9
commit
7fe93f2bb2
@ -64,6 +64,7 @@ var (
|
|||||||
ff(comm.ModuleHero, hero.StrengthenUplv): &formview.HeroStrengthenUplvView{},
|
ff(comm.ModuleHero, hero.StrengthenUplv): &formview.HeroStrengthenUplvView{},
|
||||||
ff(comm.ModuleHero, hero.StrengthenUpStar): &formview.HeroStrengthenUpStarView{},
|
ff(comm.ModuleHero, hero.StrengthenUpStar): &formview.HeroStrengthenUpStarView{},
|
||||||
ff(comm.ModuleHero, hero.DrawCard): &formview.HeroZhaomuView{},
|
ff(comm.ModuleHero, hero.DrawCard): &formview.HeroZhaomuView{},
|
||||||
|
ff(comm.ModuleHero, "info"): &formview.HeroInfoView{},
|
||||||
//equip
|
//equip
|
||||||
ff(comm.ModuleEquipment, "getlist"): &formview.EquipListView{},
|
ff(comm.ModuleEquipment, "getlist"): &formview.EquipListView{},
|
||||||
ff(comm.ModuleEquipment, "equip"): &formview.EquipUpDownView{},
|
ff(comm.ModuleEquipment, "equip"): &formview.EquipUpDownView{},
|
||||||
@ -154,6 +155,7 @@ var (
|
|||||||
ff(comm.ModuleHero, hero.StrengthenUplv),
|
ff(comm.ModuleHero, hero.StrengthenUplv),
|
||||||
ff(comm.ModuleHero, hero.StrengthenUpStar),
|
ff(comm.ModuleHero, hero.StrengthenUpStar),
|
||||||
ff(comm.ModuleHero, hero.DrawCard),
|
ff(comm.ModuleHero, hero.DrawCard),
|
||||||
|
ff(comm.ModuleHero, "info"),
|
||||||
},
|
},
|
||||||
"equipment": {
|
"equipment": {
|
||||||
ff(comm.ModuleEquipment, "getlist"),
|
ff(comm.ModuleEquipment, "getlist"),
|
||||||
@ -470,6 +472,13 @@ var (
|
|||||||
SubType: hero.DrawCard,
|
SubType: hero.DrawCard,
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
},
|
},
|
||||||
|
ff(comm.ModuleHero, "info"): {
|
||||||
|
NavLabel: "英雄信息",
|
||||||
|
Desc: "英雄信息",
|
||||||
|
MainType: string(comm.ModuleHero),
|
||||||
|
SubType: "info",
|
||||||
|
Enabled: true,
|
||||||
|
},
|
||||||
//equipment
|
//equipment
|
||||||
string(comm.ModuleEquipment): {
|
string(comm.ModuleEquipment): {
|
||||||
NavLabel: "装备",
|
NavLabel: "装备",
|
||||||
|
42
cmd/v2/ui/views/hero_info.go
Normal file
42
cmd/v2/ui/views/hero_info.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package formview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/cmd/v2/model"
|
||||||
|
"go_dreamfactory/cmd/v2/service"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/widget"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
type HeroInfoView struct {
|
||||||
|
BaseformView
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *HeroInfoView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||||
|
uidEntry := widget.NewEntry()
|
||||||
|
uidEntry.PlaceHolder = "玩家ID"
|
||||||
|
|
||||||
|
heroIdEntry := widget.NewEntry()
|
||||||
|
heroIdEntry.PlaceHolder = "英雄ObjID"
|
||||||
|
|
||||||
|
this.form.AppendItem(widget.NewFormItem("UID", uidEntry))
|
||||||
|
this.form.AppendItem(widget.NewFormItem("HeroObjID", heroIdEntry))
|
||||||
|
|
||||||
|
this.form.OnSubmit = func() {
|
||||||
|
if err := service.GetPttService().SendToClient(
|
||||||
|
t.MainType,
|
||||||
|
t.SubType,
|
||||||
|
&pb.HeroInfoReq{
|
||||||
|
Uid: uidEntry.Text,
|
||||||
|
HeroId: heroIdEntry.Text,
|
||||||
|
},
|
||||||
|
); err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return this.form
|
||||||
|
}
|
@ -89,6 +89,8 @@ type (
|
|||||||
UserOnlineList() ([]*pb.CacheUser, error)
|
UserOnlineList() ([]*pb.CacheUser, error)
|
||||||
// 跨服在线玩家列表
|
// 跨服在线玩家列表
|
||||||
CrossUserOnlineList() ([]*pb.CacheUser, error)
|
CrossUserOnlineList() ([]*pb.CacheUser, error)
|
||||||
|
// 跨服用户会话
|
||||||
|
CrossUserSession(uid string) *pb.CacheUser
|
||||||
// 跨服搜索玩家
|
// 跨服搜索玩家
|
||||||
CrossSearchUser(nickname string) ([]*pb.DBUser, error)
|
CrossSearchUser(nickname string) ([]*pb.DBUser, error)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (cod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 判断用户在线状态
|
// 判断用户在线状态
|
||||||
us := this.moduleFriend.ModuleUser.GetUserSession(userId)
|
us := this.moduleFriend.ModuleUser.CrossUserSession(userId)
|
||||||
if us != nil {
|
if us != nil {
|
||||||
base.OfflineTime = 0 //在线
|
base.OfflineTime = 0 //在线
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import (
|
|||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/db"
|
"go_dreamfactory/sys/db"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModelSession struct {
|
type ModelSession struct {
|
||||||
@ -33,7 +35,9 @@ func (this *ModelSession) Start() (err error) {
|
|||||||
func (this *ModelSession) getUserSession(uid string) (user *pb.CacheUser) {
|
func (this *ModelSession) getUserSession(uid string) (user *pb.CacheUser) {
|
||||||
user = &pb.CacheUser{}
|
user = &pb.CacheUser{}
|
||||||
if err := this.GetListObj(comm.RDS_SESSION, uid, user); err != nil {
|
if err := this.GetListObj(comm.RDS_SESSION, uid, user); err != nil {
|
||||||
|
if err != mongo.ErrNoDocuments {
|
||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return user
|
return user
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -24,6 +25,8 @@ const (
|
|||||||
Rpc_GetAllOnlineUser string = "Rpc_GetAllOnlineUser"
|
Rpc_GetAllOnlineUser string = "Rpc_GetAllOnlineUser"
|
||||||
// 跨服用户
|
// 跨服用户
|
||||||
Rpc_GetCrossUser string = "Rpc_GetCrossUser"
|
Rpc_GetCrossUser string = "Rpc_GetCrossUser"
|
||||||
|
// 跨服用户会话
|
||||||
|
Rpc_GetCrossUserSession string = "Rpc_GetCrossUserSession"
|
||||||
// 搜索用户
|
// 搜索用户
|
||||||
Rpc_QueryUser = "Rpc_QueryUser"
|
Rpc_QueryUser = "Rpc_QueryUser"
|
||||||
)
|
)
|
||||||
@ -61,6 +64,7 @@ func (this *User) Start() (err error) {
|
|||||||
event.RegisterGO(comm.EventUserOffline, this.CleanSession)
|
event.RegisterGO(comm.EventUserOffline, this.CleanSession)
|
||||||
this.service.RegisterFunctionName(Rpc_GetAllOnlineUser, this.RpcGetAllOnlineUser)
|
this.service.RegisterFunctionName(Rpc_GetAllOnlineUser, this.RpcGetAllOnlineUser)
|
||||||
this.service.RegisterFunctionName(Rpc_GetCrossUser, this.RpcGetCrossUser)
|
this.service.RegisterFunctionName(Rpc_GetCrossUser, this.RpcGetCrossUser)
|
||||||
|
this.service.RegisterFunctionName(Rpc_GetCrossUserSession, this.RpcGetCrossUserSession)
|
||||||
this.service.RegisterFunctionName(Rpc_QueryUser, this.RpcQueryUser)
|
this.service.RegisterFunctionName(Rpc_QueryUser, this.RpcQueryUser)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -121,9 +125,25 @@ func (this *User) CrossUserOnlineList() ([]*pb.CacheUser, error) {
|
|||||||
reply := &pb.UserOnlineResp{}
|
reply := &pb.UserOnlineResp{}
|
||||||
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
||||||
comm.Service_Worker, Rpc_GetAllOnlineUser, nil, reply)
|
comm.Service_Worker, Rpc_GetAllOnlineUser, nil, reply)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Rpc_GetAllOnlineUser err:%v", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return reply.Users, err
|
return reply.Users, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 跨服玩家会话
|
||||||
|
func (this *User) CrossUserSession(uid string) *pb.CacheUser {
|
||||||
|
cacheUser := &pb.CacheUser{}
|
||||||
|
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
||||||
|
comm.Service_Worker, Rpc_GetCrossUserSession, &pb.UIdReq{Uid: uid}, cacheUser)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Rpc_GetCrossUserSession err:%v", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return cacheUser
|
||||||
|
}
|
||||||
|
|
||||||
//跨服搜索用户
|
//跨服搜索用户
|
||||||
func (this *User) CrossSearchUser(nickName string) ([]*pb.DBUser, error) {
|
func (this *User) CrossSearchUser(nickName string) ([]*pb.DBUser, error) {
|
||||||
name := strings.TrimSpace(nickName)
|
name := strings.TrimSpace(nickName)
|
||||||
@ -344,6 +364,23 @@ func (this *User) RpcGetCrossUser(ctx context.Context, req *pb.UIdReq, reply *pb
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *User) RpcGetCrossUserSession(ctx context.Context, req *pb.UIdReq, reply *pb.CacheUser) error {
|
||||||
|
conn, err := db.Local()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("cross db err: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
model := db.NewDBModel(comm.TableSession, 0, conn)
|
||||||
|
if err := model.GetListObj(comm.RDS_SESSION, req.Uid, reply); err != nil {
|
||||||
|
if err != mongo.ErrNoDocuments {
|
||||||
|
log.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (this *User) RpcQueryUser(ctx context.Context, req *pb.NameReq, reply *pb.UserDataListResp) error {
|
func (this *User) RpcQueryUser(ctx context.Context, req *pb.NameReq, reply *pb.UserDataListResp) error {
|
||||||
// 区服列表
|
// 区服列表
|
||||||
for _, tag := range db.GetServerTags() {
|
for _, tag := range db.GetServerTags() {
|
||||||
|
Loading…
Reference in New Issue
Block a user