上传跨服消息分发优化

This commit is contained in:
liwei1dao 2022-09-06 18:02:46 +08:00
parent 526e32e708
commit cf65a54b8f
8 changed files with 43 additions and 73 deletions

View File

@ -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": "月之秘境"
}
]

View File

@ -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)
}
//批量读取列表中多个数据

View File

@ -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] == "~" {

View File

@ -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

View File

@ -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)
}
)

View File

@ -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)
}
//日志

View File

@ -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,

View File

@ -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 {