From cf65a54b8fabba77c35dca0a38bcff8f2cb9743f Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 6 Sep 2022 18:02:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=B7=A8=E6=9C=8D=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=88=86=E5=8F=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_msgdistrib.json | 51 +++++-------------------------- modules/comp_model.go | 2 +- modules/gateway/agent.go | 3 +- modules/gateway/configure_comp.go | 9 ++++-- modules/gateway/core.go | 2 +- modules/gateway/module.go | 4 +-- modules/moonfantasy/api_battle.go | 42 ++++++++++++------------- sys/db/dbconn.go | 3 +- 8 files changed, 43 insertions(+), 73 deletions(-) diff --git a/bin/json/game_msgdistrib.json b/bin/json/game_msgdistrib.json index d6aeafb4c..62654e849 100644 --- a/bin/json/game_msgdistrib.json +++ b/bin/json/game_msgdistrib.json @@ -1,57 +1,22 @@ [ { - "msgid": "notify.getlist", + "msgid": "notify", "routrules": "~/worker", - "describe": "公告获取接口" + "describe": "公告系统" }, { - "msgid": "forum.getlist", + "msgid": "forum", "routrules": "~/worker", - "describe": "论坛评论获取接口" + "describe": "论坛系统" }, { - "msgid": "forum.releasecomment", + "msgid": "chat", "routrules": "~/worker", - "describe": "论坛发布评论接口" + "describe": "聊天系统" }, { - "msgid": "forum.watchhero", + "msgid": "moonfantasy", "routrules": "~/worker", - "describe": "论坛查看目标英雄接口" - }, - { - "msgid": "chat.crosschannel", - "routrules": "~/worker", - "describe": "聊天系统跨服聊天频道请求" - }, - { - "msgid": "chat.chanagechannel", - "routrules": "~/worker", - "describe": "切换聊天频道" - }, - { - "msgid": "chat.getlist", - "routrules": "~/worker", - "describe": "获取聊天记录" - }, - { - "msgid": "chat.send", - "routrules": "~/worker", - "describe": "聊天消息发送" - }, - { - "msgid": "forum.like", - "routrules": "~/worker", - "describe": "论坛点赞入口" - }, - { - "msgid": "moonfantasy.trigger", - "routrules": "~/worker", - "describe": "月之秘境触发接口" - }, - { - "msgid": "moonfantasy.dare", - "routrules": "~/worker", - "describe": "月之秘境参战接口" + "describe": "月之秘境" } ] \ No newline at end of file diff --git a/modules/comp_model.go b/modules/comp_model.go index 5b7193ea9..db8bc3f25 100644 --- a/modules/comp_model.go +++ b/modules/comp_model.go @@ -112,7 +112,7 @@ func (this *MCompModel) GetListFields(uid string, id string, data interface{}, f //读取列表数据中单个数据 func (this *MCompModel) GetListObj(uid string, id string, data interface{}) (err error) { - return this.DBModel.GetListObj(uid, id, data) + return this.DBModel.GetListObj(uid, id, data) } //批量读取列表中多个数据 diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index 6171f8dfd..470ae5bf2 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -240,8 +240,7 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) { req.SubType = msg.SubType req.Message = msg.Data - msgid := strings.ToLower(fmt.Sprintf("%s.%s", msg.MainType, msg.SubType)) - if rule, ok = this.gateway.GetMsgDistribute(msgid); ok { + if rule, ok = this.gateway.GetMsgDistribute(req.MainType, req.SubType); ok { paths := strings.Split(rule, "/") if len(paths) == 3 { if paths[0] == "~" { diff --git a/modules/gateway/configure_comp.go b/modules/gateway/configure_comp.go index a3f80cc38..4403fddff 100644 --- a/modules/gateway/configure_comp.go +++ b/modules/gateway/configure_comp.go @@ -1,8 +1,10 @@ package gateway import ( + "fmt" "go_dreamfactory/modules" cfg "go_dreamfactory/sys/configure/structs" + "strings" "go_dreamfactory/lego/core" ) @@ -24,7 +26,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp } // GetMsgDistribute 获取消息分发规则读取配置表 -func (this *configureComp) GetMsgDistribute(msgid string) (rule string, ok bool) { +func (this *configureComp) GetMsgDistribute(msgmid, msguid string) (rule string, ok bool) { var ( err error v interface{} @@ -34,8 +36,11 @@ func (this *configureComp) GetMsgDistribute(msgid string) (rule string, ok bool) ok = false return } else { - if item, ok = v.(*cfg.GameMsgdistrib).GetDataMap()[msgid]; ok { + if item, ok = v.(*cfg.GameMsgdistrib).GetDataMap()[msgmid]; ok { rule = item.Routrules + } else { + msgid := strings.ToLower(fmt.Sprintf("%s.%s", msgmid, msguid)) + item, ok = v.(*cfg.GameMsgdistrib).GetDataMap()[msgid] } } return diff --git a/modules/gateway/core.go b/modules/gateway/core.go index 6b32d844e..779e64ff6 100644 --- a/modules/gateway/core.go +++ b/modules/gateway/core.go @@ -29,7 +29,7 @@ type ( CrossServiceTag() string Connect(a IAgent) DisConnect(a IAgent) - GetMsgDistribute(msgid string) (rule string, ok bool) + GetMsgDistribute(msgmid, msguid string) (rule string, ok bool) } ) diff --git a/modules/gateway/module.go b/modules/gateway/module.go index 29e39ec4b..54150dbee 100644 --- a/modules/gateway/module.go +++ b/modules/gateway/module.go @@ -102,8 +102,8 @@ func (this *Gateway) DisConnect(a IAgent) { } // GetMsgDistribute 读取消息分发规则 -func (this *Gateway) GetMsgDistribute(msgid string) (rule string, ok bool) { - return this.configure.GetMsgDistribute(msgid) +func (this *Gateway) GetMsgDistribute(msgmid, msguid string) (rule string, ok bool) { + return this.configure.GetMsgDistribute(msgmid, msguid) } //日志 diff --git a/modules/moonfantasy/api_battle.go b/modules/moonfantasy/api_battle.go index 92cbf5fac..cad35acc7 100644 --- a/modules/moonfantasy/api_battle.go +++ b/modules/moonfantasy/api_battle.go @@ -20,29 +20,29 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle globalconf *cfg.GameGlobalData boss *cfg.GameDreamlandBoosData mdata *pb.DBMoonfantasy - record *pb.DBBattleRecord - cd pb.ErrorCode - err error + // record *pb.DBBattleRecord + cd pb.ErrorCode + err error ) defer func() { - if cd == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), "dare", &pb.MoonfantasyBattleResp{ - Code: cd, - Monster: mdata.Monster, - Info: &pb.BattleInfo{ - Id: record.Id, - Btype: record.Btype, - Ptype: record.Ptype, - RedCompId: record.RedCompId, - Redflist: record.Redflist, - BlueCompId: record.BlueCompId, - Buleflist: record.Buleflist, - }, - }) - } else { - session.SendMsg(string(this.module.GetType()), "dare", &pb.MoonfantasyBattleResp{Code: cd}) - } + // if cd == pb.ErrorCode_Success { + // session.SendMsg(string(this.module.GetType()), "dare", &pb.MoonfantasyBattleResp{ + // Code: cd, + // Monster: mdata.Monster, + // Info: &pb.BattleInfo{ + // Id: record.Id, + // Btype: record.Btype, + // Ptype: record.Ptype, + // RedCompId: record.RedCompId, + // Redflist: record.Redflist, + // BlueCompId: record.BlueCompId, + // Buleflist: record.Buleflist, + // }, + // }) + // } else { + session.SendMsg(string(this.module.GetType()), "dare", &pb.MoonfantasyBattleResp{Code: cd}) + // } }() @@ -84,7 +84,7 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle } else { mdata.Record[session.GetUserId()] = 1 } - code, record = this.module.battle.CreatePvbBattle(session, &pb.BattlePVEReq{ + cd, _ = this.module.battle.CreatePvbBattle(session, &pb.BattlePVEReq{ Ptype: pb.PlayType_moonfantasy, Leadpos: req.Leadpos, Teamids: req.Teamids, diff --git a/sys/db/dbconn.go b/sys/db/dbconn.go index 7542d1481..4bd5ec27a 100644 --- a/sys/db/dbconn.go +++ b/sys/db/dbconn.go @@ -592,7 +592,8 @@ func (this *DBModel) GetListObj(uid string, id string, data interface{}) (err er return err } else { pipe := this.Redis.RedisPipe(context.TODO()) - dtype := reflect2.TypeOf(data).(*reflect2.UnsafeStructType) + // dtype := reflect2.TypeOf(data).(*reflect2.UnsafeStructType) + dtype := reflect2.TypeOf(data).(*reflect2.UnsafePtrType).Elem().(*reflect2.UnsafeStructType) for c.Next(context.Background()) { _id := c.Current.Lookup("_id").StringValue() if _id != id {