上传 秘境与聊天系统跨服升级

This commit is contained in:
liwei1dao 2022-10-19 14:19:23 +08:00
parent 1a3030da01
commit eb93beb54a
19 changed files with 719 additions and 309 deletions

View File

@ -11,6 +11,12 @@
"routrules": "~/worker", "routrules": "~/worker",
"describe": "论坛系统" "describe": "论坛系统"
}, },
{
"msgid": "chat",
"open": true,
"routrules": "~/worker",
"describe": "聊天系统"
},
{ {
"msgid": "chat.chanagechannel", "msgid": "chat.chanagechannel",
"open": true, "open": true,
@ -46,5 +52,23 @@
"open": true, "open": true,
"routrules": "~/worker", "routrules": "~/worker",
"describe": "查询英雄详细" "describe": "查询英雄详细"
},
{
"msgid": "friend.apply",
"open": true,
"routrules": "~/worker",
"describe": "好友申请"
},
{
"msgid": "friend.agree",
"open": true,
"routrules": "~/worker",
"describe": "同意"
},
{
"msgid": "friend.refuse",
"open": true,
"routrules": "~/worker",
"describe": "拒绝"
} }
] ]

View File

@ -161,6 +161,8 @@ const ( //Rpc
Rpc_GatewayNoticeUserClose core.Rpc_Key = "Rpc_NoticeUserClose" //通知用户离线 Rpc_GatewayNoticeUserClose core.Rpc_Key = "Rpc_NoticeUserClose" //通知用户离线
//GM 后台消息 //GM 后台消息
Rpc_GMReleaseChatSystemMessage core.Rpc_Key = "Rpc_GMChatReleaseSystemMessage" //发布聊天系统消息 Rpc_GMReleaseChatSystemMessage core.Rpc_Key = "Rpc_GMChatReleaseSystemMessage" //发布聊天系统消息
//Moonfantasy 月之秘境
Rpc_ModuleMoonfantasyTrigger core.Rpc_Key = "Rpc_ModuleMoonfantasyTrigger" //月之秘境触发消息
) )
//事件类型定义处 //事件类型定义处

View File

@ -142,14 +142,17 @@ func (this *UserSession) Polls() []*pb.UserMessage {
return msgs return msgs
} }
//推送消息到用户
func (this *UserSession) Push() (err error) { func (this *UserSession) Push() (err error) {
reply := &pb.RPCMessageReply{} // reply := &pb.RPCMessageReply{}
if len(this.msgqueue) > 0 {
if _, err = this.service.AcrossClusterRpcGo(context.Background(), this.ServiceTag, fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{ if _, err = this.service.AcrossClusterRpcGo(context.Background(), this.ServiceTag, fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{
UserSessionId: this.SessionId, UserSessionId: this.SessionId,
Reply: this.msgqueue, Reply: this.msgqueue,
}, reply); err != nil { }, nil); err != nil {
log.Errorf("SendMsgToUsers:%v err:%v", this, err) log.Errorf("SendMsgToUsers:%v err:%v", this, err)
} }
}
return return
} }

View File

@ -0,0 +1,77 @@
package chat
// import (
// "go_dreamfactory/comm"
// "go_dreamfactory/pb"
// "google.golang.org/protobuf/proto"
// )
// //参数校验
// func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.ChatGetListReq) (code pb.ErrorCode) {
// if req.Channel == pb.ChatChannel_World && req.ChannelId == 0 {
// code = pb.ErrorCode_ReqParameterError
// }
// return
// }
// ///获取本服聊天消息记录
// func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq) (code pb.ErrorCode, data proto.Message) {
// var (
// err error
// // result *pb.DBUserExpand
// list []*pb.DBChat
// )
// if code = this.GetListCheck(session, req); code != pb.ErrorCode_Success {
// return
// }
// switch req.Channel {
// case pb.ChatChannel_World:
// if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
// case pb.ChatChannel_Union:
// if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
// case pb.ChatChannel_Private:
// if list, err = this.module.modelChat.QueryUserMsg(session.GetUserId()); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
// // case pb.ChatChannel_CrossServer:
// // if result, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
// // this.module.Errorf("err:%v", err)
// // code = pb.ErrorCode_DBError
// // return
// // }
// // if req.ChannelId != result.Chatchannel {
// // code = pb.ErrorCode_ReqParameterError
// // return
// // }
// // if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", req.ChannelId); err != nil {
// // code = pb.ErrorCode_DBError
// // return
// // }
// // break
// case pb.ChatChannel_System:
// if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
// default:
// code = pb.ErrorCode_ReqParameterError
// this.module.Errorf("getlist no support channel:%d ", req.Channel)
// return
// }
// session.SendMsg(string(this.module.GetType()), "getlist", &pb.ChatGetListResp{Chats: list})
// return
// }

116
modules/chat/__api_send.go Normal file
View File

@ -0,0 +1,116 @@
package chat
// import (
// "fmt"
// "go_dreamfactory/comm"
// "go_dreamfactory/pb"
// "time"
// "go.mongodb.org/mongo-driver/bson/primitive"
// "google.golang.org/protobuf/proto"
// )
// //参数校验
// func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.ChatSendReq) (code pb.ErrorCode) {
// if (req.Channel == pb.ChatChannel_Union && req.TargetId == "") || (req.Channel == pb.ChatChannel_Private && req.TargetId == "") {
// code = pb.ErrorCode_ReqParameterError
// }
// return
// }
// ///消息发送请求
// func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code pb.ErrorCode, data proto.Message) {
// var (
// err error
// max int32
// msg *pb.DBChat
// // userexpand *pb.DBUserExpand
// max_chat int32
// )
// if code = this.SendCheck(session, req); code != pb.ErrorCode_Success {
// return
// }
// msg = &pb.DBChat{
// Id: primitive.NewObjectID().Hex(),
// Channel: req.Channel,
// Suid: session.GetUserId(),
// Slv: req.Ulv,
// Uname: req.Uname,
// Avatar: req.Avatar,
// Stag: session.GetServiecTag(),
// Ctype: req.Ctype,
// Content: req.Content,
// Ctime: time.Now().Unix(),
// AppendInt: req.AppendInt,
// AppendStr: req.AppendStr,
// AppendBool: req.AppendBool,
// AppendBytes: req.AppendBytes,
// }
// if max, err = this.module.configure.GetChannelRecordMax(); err != nil {
// code = pb.ErrorCode_ConfigNoFound
// return
// }
// if max_chat, err = this.module.configure.GetChannelRecordMax(); err != nil {
// code = pb.ErrorCode_ConfigNoFound
// return
// }
// switch msg.Channel {
// case pb.ChatChannel_World:
// if this.module.options.GM { //判断gm命令
// if code = this.module.gm.CreateCmd(session, req.Content); code == pb.ErrorCode_Success {
// session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{Issucc: true})
// return
// }
// code = pb.ErrorCode_Success
// }
// if err = this.module.modelChat.addChatMsg(worldchatkey, int64(max), msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// if err = this.module.PushWorld(msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// //随机任务
// this.module.ModuleRtask.SendToRtask(session, comm.Rtype62, 1)
// break
// case pb.ChatChannel_Union:
// msg.UnionId = req.TargetId
// if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s:%s", unionchatkey, req.TargetId), int64(max_chat), msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// if err = this.module.PushUnion(req.TargetId, msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
// case pb.ChatChannel_Private:
// msg.Ruid = req.TargetId
// if err = this.module.PushUser(msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// session.SendMsg(string(this.module.GetType()), "message", &pb.ChatMessagePush{Chat: msg})
// break
// // case pb.ChatChannel_CrossServer:
// // if userexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
// // code = pb.ErrorCode_DBError
// // return
// // }
// // msg.ChannelId = userexpand.Chatchannel //指定频道
// // if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%d", crosschatkey, userexpand.Chatchannel), int64(max_chat), msg); err != nil {
// // code = pb.ErrorCode_DBError
// // return
// // }
// // this.module.PushToUsers(userexpand.Chatchannel, msg)
// default:
// code = pb.ErrorCode_ReqParameterError
// this.module.Errorf("getlist no support channel:%d ", req.Channel)
// return
// }
// session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{Issucc: true})
// return
// }

View File

@ -1,77 +0,0 @@
package chat
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) GetCrossListCheck(session comm.IUserSession, req *pb.ChatGetCrossListReq) (code pb.ErrorCode) {
if req.Channel == pb.ChatChannel_World && req.ChannelId == 0 {
code = pb.ErrorCode_ReqParameterError
}
return
}
///获取本服聊天消息记录
func (this *apiComp) GetCrossList(session comm.IUserSession, req *pb.ChatGetCrossListReq) (code pb.ErrorCode, data proto.Message) {
var (
err error
result *pb.DBUserExpand
list []*pb.DBChat
)
if code = this.GetCrossListCheck(session, req); code != pb.ErrorCode_Success {
return
}
switch req.Channel {
// case pb.ChatChannel_World:
// if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
// case pb.ChatChannel_Union:
// if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
// case pb.ChatChannel_Private:
// if list, err = this.module.modelChat.QueryUserMsg(session.GetUserId()); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
case pb.ChatChannel_CrossServer:
if result, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
this.module.Errorf("err:%v", err)
code = pb.ErrorCode_DBError
return
}
if req.ChannelId != result.Chatchannel {
code = pb.ErrorCode_ReqParameterError
return
}
if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", req.ChannelId); err != nil {
code = pb.ErrorCode_DBError
return
}
break
// case pb.ChatChannel_System:
// if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
default:
code = pb.ErrorCode_ReqParameterError
this.module.Errorf("getlist no support channel:%d ", req.Channel)
return
}
session.SendMsg(string(this.module.GetType()), "getcrosslist", &pb.ChatGetCrossListResp{Chats: list})
return
}

View File

@ -8,7 +8,7 @@ import (
) )
//参数校验 //参数校验
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.ChatGetListReq) (code pb.ErrorCode) { func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.ChatGetCrossListReq) (code pb.ErrorCode) {
if req.Channel == pb.ChatChannel_World && req.ChannelId == 0 { if req.Channel == pb.ChatChannel_World && req.ChannelId == 0 {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
@ -16,10 +16,10 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.ChatGetList
} }
///获取本服聊天消息记录 ///获取本服聊天消息记录
func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetCrossListReq) (code pb.ErrorCode, data proto.Message) {
var ( var (
err error err error
// result *pb.DBUserExpand result *pb.DBUserExpand
list []*pb.DBChat list []*pb.DBChat
) )
@ -46,32 +46,32 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
return return
} }
break break
// case pb.ChatChannel_CrossServer: case pb.ChatChannel_CrossServer:
// if result, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil { if result, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
// this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
// code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
// return return
// } }
// if req.ChannelId != result.Chatchannel { if req.ChannelId != result.Chatchannel {
// code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
// return return
// } }
// if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", req.ChannelId); err != nil { if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", req.ChannelId); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
case pb.ChatChannel_System:
if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
break break
// case pb.ChatChannel_System:
// if list, err = this.module.modelChat.getChatQueue(req.Channel, session.GetServiecTag(), "", 0); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
default: default:
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
this.module.Errorf("getlist no support channel:%d ", req.Channel) this.module.Errorf("getlist no support channel:%d ", req.Channel)
return return
} }
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ChatGetListResp{Chats: list}) session.SendMsg(string(this.module.GetType()), "getcrosslist", &pb.ChatGetCrossListResp{Chats: list})
return return
} }

View File

@ -11,7 +11,7 @@ import (
) )
//参数校验 //参数校验
func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.ChatSendReq) (code pb.ErrorCode) { func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.ChatSendCrossReq) (code pb.ErrorCode) {
if (req.Channel == pb.ChatChannel_Union && req.TargetId == "") || (req.Channel == pb.ChatChannel_Private && req.TargetId == "") { if (req.Channel == pb.ChatChannel_Union && req.TargetId == "") || (req.Channel == pb.ChatChannel_Private && req.TargetId == "") {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
@ -19,12 +19,12 @@ func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.ChatSendReq) (
} }
///消息发送请求 ///消息发送请求
func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendCrossReq) (code pb.ErrorCode, data proto.Message) {
var ( var (
err error err error
max int32 max int32
msg *pb.DBChat msg *pb.DBChat
// userexpand *pb.DBUserExpand userexpand *pb.DBUserExpand
max_chat int32 max_chat int32
) )
if code = this.SendCheck(session, req); code != pb.ErrorCode_Success { if code = this.SendCheck(session, req); code != pb.ErrorCode_Success {
@ -58,14 +58,14 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
switch msg.Channel { switch msg.Channel {
case pb.ChatChannel_World: case pb.ChatChannel_World:
if this.module.options.GM { //判断gm命令 if this.module.options.GM { //判断gm命令
if code = this.module.gm.CreateCmd(session, req.Content); code == pb.ErrorCode_Success { if IsCmd(req.Content) { //是否是GM命令
session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{Issucc: true}) session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{Issucc: true})
return return
} }
code = pb.ErrorCode_Success code = pb.ErrorCode_Success
} }
if err = this.module.modelChat.addChatMsg(worldchatkey, int64(max), msg); err != nil { if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", worldchatkey, session.GetServiecTag()), int64(max), msg); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
@ -74,7 +74,7 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
return return
} }
//随机任务 //随机任务
this.module.ModuleRtask.SendToRtask(session, comm.Rtype62, 1) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype62, 1)
break break
case pb.ChatChannel_Union: case pb.ChatChannel_Union:
msg.UnionId = req.TargetId msg.UnionId = req.TargetId
@ -87,30 +87,31 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code
return return
} }
break break
// case pb.ChatChannel_Private: case pb.ChatChannel_Private:
// msg.Ruid = req.TargetId msg.Ruid = req.TargetId
// if err = this.module.PushUser(msg); err != nil { if err = this.module.PushUser(msg); err != nil {
// code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
// return return
// } }
// session.SendMsg(string(this.module.GetType()), "message", &pb.ChatMessagePush{Chat: msg}) session.SendMsg(string(this.module.GetType()), "message", &pb.ChatMessagePush{Chat: msg})
// break break
// case pb.ChatChannel_CrossServer: case pb.ChatChannel_CrossServer:
// if userexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil { if userexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
// code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
// return return
// } }
// msg.ChannelId = userexpand.Chatchannel //指定频道 msg.ChannelId = userexpand.Chatchannel //指定频道
// if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%d", crosschatkey, userexpand.Chatchannel), int64(max_chat), msg); err != nil { if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%d", crosschatkey, userexpand.Chatchannel), int64(max_chat), msg); err != nil {
// code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
// return return
// } }
// this.module.PushToUsers(userexpand.Chatchannel, msg) this.module.PushToUsers(userexpand.Chatchannel, msg)
break
default: default:
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
this.module.Errorf("getlist no support channel:%d ", req.Channel) this.module.Errorf("getlist no support channel:%d ", req.Channel)
return return
} }
session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{Issucc: true}) session.SendMsg(string(this.module.GetType()), "sendcross", &pb.ChatSendCrossResp{Issucc: true})
return return
} }

View File

@ -1,117 +0,0 @@
package chat
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) SendCrossCheck(session comm.IUserSession, req *pb.ChatSendCrossReq) (code pb.ErrorCode) {
if (req.Channel == pb.ChatChannel_Union && req.TargetId == "") || (req.Channel == pb.ChatChannel_Private && req.TargetId == "") {
code = pb.ErrorCode_ReqParameterError
}
return
}
///消息发送请求
func (this *apiComp) SendCross(session comm.IUserSession, req *pb.ChatSendCrossReq) (code pb.ErrorCode, data proto.Message) {
var (
err error
// max int32
msg *pb.DBChat
userexpand *pb.DBUserExpand
max_chat int32
)
if code = this.SendCrossCheck(session, req); code != pb.ErrorCode_Success {
return
}
msg = &pb.DBChat{
Id: primitive.NewObjectID().Hex(),
Channel: req.Channel,
Suid: session.GetUserId(),
Slv: req.Ulv,
Uname: req.Uname,
Avatar: req.Avatar,
Stag: session.GetServiecTag(),
Ctype: req.Ctype,
Content: req.Content,
Ctime: time.Now().Unix(),
AppendInt: req.AppendInt,
AppendStr: req.AppendStr,
AppendBool: req.AppendBool,
AppendBytes: req.AppendBytes,
}
// if max, err = this.module.configure.GetChannelRecordMax(); err != nil {
// code = pb.ErrorCode_ConfigNoFound
// return
// }
if max_chat, err = this.module.configure.GetChannelRecordMax(); err != nil {
code = pb.ErrorCode_ConfigNoFound
return
}
switch msg.Channel {
// case pb.ChatChannel_World:
// if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", worldchatkey, session.GetServiecTag()), int64(max), msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// if err = this.module.PushWorld(msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// //随机任务
// this.module.ModuleRtask.SendToRtask(session, comm.Rtype62, 1)
// break
// case pb.ChatChannel_Union:
// msg.UnionId = req.TargetId
// if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s:%s", unionchatkey, req.TargetId), int64(max_chat), msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// if err = this.module.PushUnion(req.TargetId, msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
// case pb.ChatChannel_Private:
// msg.Ruid = req.TargetId
// if err = this.module.PushUser(msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// session.SendMsg(string(this.module.GetType()), "message", &pb.ChatMessagePush{Chat: msg})
// break
case pb.ChatChannel_Private:
msg.Ruid = req.TargetId
if err = this.module.PushUser(msg); err != nil {
code = pb.ErrorCode_DBError
return
}
session.SendMsg(string(this.module.GetType()), "message", &pb.ChatMessagePush{Chat: msg})
break
case pb.ChatChannel_CrossServer:
if userexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
code = pb.ErrorCode_DBError
return
}
msg.ChannelId = userexpand.Chatchannel //指定频道
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%d", crosschatkey, userexpand.Chatchannel), int64(max_chat), msg); err != nil {
code = pb.ErrorCode_DBError
return
}
this.module.PushToUsers(userexpand.Chatchannel, msg)
break
default:
code = pb.ErrorCode_ReqParameterError
this.module.Errorf("getlist no support channel:%d ", req.Channel)
return
}
session.SendMsg(string(this.module.GetType()), "sendcross", &pb.ChatSendCrossResp{Issucc: true})
return
}

13
modules/chat/core.go Normal file
View File

@ -0,0 +1,13 @@
package chat
import "strings"
func IsCmd(cmd string) bool {
keys := strings.Split(cmd, ":")
if len(keys) == 2 {
if keys[0] == "bingo" {
return true
}
}
return false
}

View File

@ -75,7 +75,8 @@ func (this *modelChatComp) getChatQueue(channel pb.ChatChannel, stag, union stri
) )
switch channel { switch channel {
case pb.ChatChannel_World: case pb.ChatChannel_World:
key = worldchatkey // key = worldchatkey
key = fmt.Sprintf("%s-%s", worldchatkey, stag)
find = bson.M{"channel": channel} find = bson.M{"channel": channel}
break break
case pb.ChatChannel_Union: case pb.ChatChannel_Union:
@ -240,7 +241,7 @@ func (this *modelChatComp) sendWorldChat(msg *pb.DBChat) (code pb.ErrorCode) {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }
if err = this.module.modelChat.addChatMsg(worldchatkey, int64(max), msg); err != nil { if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", worldchatkey, msg.Stag), int64(max), msg); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }

View File

@ -104,6 +104,11 @@ func (this *ModuleBase) Start() (err error) {
return return
} }
//判断当前环境是本服还还是跨服
func (this *ModuleBase) IsCross() bool {
return db.IsCross()
}
//获取跨服标签 //获取跨服标签
func (this *ModuleBase) GetCrossTag() string { func (this *ModuleBase) GetCrossTag() string {
return db.CrossTag() return db.CrossTag()

View File

@ -4,13 +4,11 @@ import (
"fmt" "fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/lego/sys/redis" "go_dreamfactory/lego/sys/redis"
"go_dreamfactory/lego/sys/timewheel" "go_dreamfactory/lego/sys/timewheel"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db"
"time" "time"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
@ -86,7 +84,7 @@ func (this *modelDreamComp) addDreamData(user *pb.UserInfo, boss *cfg.GameDreaml
} }
//触发月之秘境 //触发月之秘境
func (this *modelDreamComp) trigger(session comm.IUserSession, source *pb.BattleReport) { func (this *modelDreamComp) trigger(session comm.IUserSession) {
var ( var (
user *pb.DBUser user *pb.DBUser
umfantasy *pb.DBUserMFantasy umfantasy *pb.DBUserMFantasy
@ -153,20 +151,22 @@ func (this *modelDreamComp) trigger(session comm.IUserSession, source *pb.Battle
///查询好友数据 ///查询好友数据
func (this *modelDreamComp) noticeuserfriend(session comm.IUserSession, mid string, chat *pb.DBChat) (code pb.ErrorCode) { func (this *modelDreamComp) noticeuserfriend(session comm.IUserSession, mid string, chat *pb.DBChat) (code pb.ErrorCode) {
var ( var (
model *db.DBModel // model *db.DBModel
err error // err error
friend []string
) )
if model, err = this.module.GetDBNodule(session, comm.TableFriend, 0); err != nil { // if model, err = this.module.GetDBNodule(session, comm.TableFriend, 0); err != nil {
code = pb.ErrorCode_DBError // code = pb.ErrorCode_DBError
this.module.Errorf("session:%v err:%v", session, err) // this.module.Errorf("session:%v err:%v", session, err)
return // return
} // }
friend := &pb.DBFriend{Uid: session.GetUserId(), FriendIds: make([]string, 0)} // friend := &pb.DBFriend{Uid: session.GetUserId(), FriendIds: make([]string, 0)}
if err = model.Get(session.GetUserId(), friend); err != nil && err != mgo.MongodbNil { // if err = model.Get(session.GetUserId(), friend); err != nil && err != mgo.MongodbNil {
this.module.Errorln(err) // this.module.Errorln(err)
return // return
} // }
for _, v := range friend.FriendIds { friend = this.module.friend.GetFriendList(session.GetUserId())
for _, v := range friend {
temp := *chat temp := *chat
temp.Id = primitive.NewObjectID().Hex() temp.Id = primitive.NewObjectID().Hex()
temp.Channel = pb.ChatChannel_Private temp.Channel = pb.ChatChannel_Private
@ -175,13 +175,14 @@ func (this *modelDreamComp) noticeuserfriend(session comm.IUserSession, mid stri
} }
chat.Id = primitive.NewObjectID().Hex() chat.Id = primitive.NewObjectID().Hex()
chat.Channel = pb.ChatChannel_World chat.Channel = pb.ChatChannel_World
chat.Stag = session.GetServiecTag()
// code = this.module.chat.SendWorldChat(stag, chat) // code = this.module.chat.SendWorldChat(stag, chat)
this.delaynoticeWorld(session.GetServiecTag(), mid, chat) this.delaynoticeWorld(mid, chat)
return return
} }
//延迟推送到 世界聊天频道 //延迟推送到 世界聊天频道
func (this *modelDreamComp) delaynoticeWorld(stag, mid string, chat *pb.DBChat) { func (this *modelDreamComp) delaynoticeWorld(mid string, chat *pb.DBChat) {
timewheel.Add(time.Minute*15, func(t *timewheel.Task, i ...interface{}) { timewheel.Add(time.Minute*15, func(t *timewheel.Task, i ...interface{}) {
_mid := i[0].(string) _mid := i[0].(string)
_chat := i[1].(*pb.DBChat) _chat := i[1].(*pb.DBChat)

View File

@ -1,10 +1,14 @@
package moonfantasy package moonfantasy
import ( import (
"context"
"crypto/rand" "crypto/rand"
"errors"
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/base" "go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
@ -25,6 +29,7 @@ type Moonfantasy struct {
modules.ModuleBase modules.ModuleBase
service base.IRPCXService service base.IRPCXService
chat comm.IChat chat comm.IChat
friend comm.IFriend
battle comm.IBattle battle comm.IBattle
api_comp *apiComp api_comp *apiComp
configure *configureComp configure *configureComp
@ -51,10 +56,15 @@ func (this *Moonfantasy) Start() (err error) {
return return
} }
this.chat = module.(comm.IChat) this.chat = module.(comm.IChat)
if module, err = this.service.GetModule(comm.ModuleFriend); err != nil {
return
}
this.friend = module.(comm.IFriend)
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil { if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
return return
} }
this.battle = module.(comm.IBattle) this.battle = module.(comm.IBattle)
this.service.RegisterFunctionName(string(comm.Rpc_ModuleMoonfantasyTrigger), this.Rpc_ModuleMoonfantasyTrigger)
return return
} }
@ -76,7 +86,36 @@ func (this *Moonfantasy) Trigger(session comm.IUserSession, source *pb.BattleRep
if triggerData, err = this.configure.GettriggerData(int32(source.Info.Ptype)); err == nil && triggerData.Open { if triggerData, err = this.configure.GettriggerData(int32(source.Info.Ptype)); err == nil && triggerData.Open {
n, _ := rand.Int(rand.Reader, big.NewInt(1000)) n, _ := rand.Int(rand.Reader, big.NewInt(1000))
if int32(n.Int64()) < triggerData.DreamlandPro { if int32(n.Int64()) < triggerData.DreamlandPro {
this.modelDream.trigger(session, source) if this.IsCross() {
this.modelDream.trigger(session)
} else {
if _, err = this.service.AcrossClusterRpcGo(context.Background(),
this.GetCrossTag(),
comm.Service_Worker,
string(comm.Rpc_ModuleMoonfantasyTrigger),
pb.RPCGeneralReqA1{Param1: session.GetUserId()},
nil,
); err != nil {
this.Errorln(err)
} }
} }
} }
}
}
//接收区服worker发起的秘境事件
func (this *Moonfantasy) Rpc_ModuleMoonfantasyTrigger(ctx context.Context, args *pb.RPCGeneralReqA1, reply *pb.EmptyResp) (err error) {
this.Debug("Rpc_ModuleMoonfantasyTrigger", log.Field{Key: "args", Value: args.String()})
if args.Param1 == "" {
err = errors.New("参数异常!")
return
}
if session, ok := this.GetUserSession(args.Param1); !ok {
err = fmt.Errorf("未查询到用户:%s在线信息!", args.Param1)
return
} else {
this.modelDream.trigger(session)
session.Push()
}
return
}

View File

@ -90,7 +90,7 @@ func (this *ChatComp) chatNoticen(content string) func() {
} }
data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg}) data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})
this.module.Debug("广播公告消息", log.Field{Key: "chat", Value: content}) this.module.Debug("广播公告消息", log.Field{Key: "chat", Value: content})
if err := this.module.service.AcrossClusterBroadcast(context.Background(), msg.Stag, comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{ if err := this.module.service.RpcBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{
MainType: string(comm.ModuleChat), MainType: string(comm.ModuleChat),
SubType: "message", SubType: "message",
Data: data, Data: data,

View File

@ -145,8 +145,8 @@ type DBChat struct {
Suid string `protobuf:"bytes,4,opt,name=suid,proto3" json:"suid"` //发送用户id Suid string `protobuf:"bytes,4,opt,name=suid,proto3" json:"suid"` //发送用户id
Slv int32 `protobuf:"varint,5,opt,name=slv,proto3" json:"slv"` //发送者等级 Slv int32 `protobuf:"varint,5,opt,name=slv,proto3" json:"slv"` //发送者等级
Ruid string `protobuf:"bytes,6,opt,name=ruid,proto3" json:"ruid"` //接收用户id channel == Private 有效 Ruid string `protobuf:"bytes,6,opt,name=ruid,proto3" json:"ruid"` //接收用户id channel == Private 有效
ChannelId int32 `protobuf:"varint,7,opt,name=channelId,proto3" json:"channelId"` //跨服频道 频道Id ChannelId int32 `protobuf:"varint,7,opt,name=channelId,proto3" json:"channelId" bson:"channelId"` //ID跨服频道 频道Id
UnionId string `protobuf:"bytes,8,opt,name=unionId,proto3" json:"unionId"` //工会id UnionId string `protobuf:"bytes,8,opt,name=unionId,proto3" json:"unionId"` //@go_tags(`bson:"unionId"`)工会id
Stag string `protobuf:"bytes,9,opt,name=stag,proto3" json:"stag"` //区服id Stag string `protobuf:"bytes,9,opt,name=stag,proto3" json:"stag"` //区服id
Avatar string `protobuf:"bytes,10,opt,name=avatar,proto3" json:"avatar"` //用户头像 Avatar string `protobuf:"bytes,10,opt,name=avatar,proto3" json:"avatar"` //用户头像
Uname string `protobuf:"bytes,11,opt,name=uname,proto3" json:"uname"` //用户名 Uname string `protobuf:"bytes,11,opt,name=uname,proto3" json:"uname"` //用户名
@ -155,7 +155,7 @@ type DBChat struct {
AppendInt int64 `protobuf:"varint,14,opt,name=appendInt,proto3" json:"appendInt" bson:"appendInt"` //聊天附加数据 AppendInt int64 `protobuf:"varint,14,opt,name=appendInt,proto3" json:"appendInt" bson:"appendInt"` //聊天附加数据
AppendStr string `protobuf:"bytes,15,opt,name=appendStr,proto3" json:"appendStr" bson:"appendStr"` //聊天附加数据 AppendStr string `protobuf:"bytes,15,opt,name=appendStr,proto3" json:"appendStr" bson:"appendStr"` //聊天附加数据
AppendBool string `protobuf:"bytes,16,opt,name=appendBool,proto3" json:"appendBool" bson:"appendBool"` //聊天附加数据 AppendBool string `protobuf:"bytes,16,opt,name=appendBool,proto3" json:"appendBool" bson:"appendBool"` //聊天附加数据
AppendBytes []byte `protobuf:"bytes,17,opt,name=appendBytes,proto3" json:"appendBytes" bson:"appendInt"` //聊天附加数据 AppendBytes []byte `protobuf:"bytes,17,opt,name=appendBytes,proto3" json:"appendBytes" bson:"appendBytes"` //聊天附加数据
} }
func (x *DBChat) Reset() { func (x *DBChat) Reset() {

View File

@ -1190,6 +1190,246 @@ func (*EmptyResp) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{17} return file_comm_proto_rawDescGZIP(), []int{17}
} }
// rpc 通用请求消息 1
type RPCGeneralReqA1 struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Param1 string `protobuf:"bytes,1,opt,name=param1,proto3" json:"param1"`
}
func (x *RPCGeneralReqA1) Reset() {
*x = RPCGeneralReqA1{}
if protoimpl.UnsafeEnabled {
mi := &file_comm_proto_msgTypes[18]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RPCGeneralReqA1) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RPCGeneralReqA1) ProtoMessage() {}
func (x *RPCGeneralReqA1) ProtoReflect() protoreflect.Message {
mi := &file_comm_proto_msgTypes[18]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RPCGeneralReqA1.ProtoReflect.Descriptor instead.
func (*RPCGeneralReqA1) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{18}
}
func (x *RPCGeneralReqA1) GetParam1() string {
if x != nil {
return x.Param1
}
return ""
}
// rpc 通用请求消息 1
type RPCGeneralReqA2 struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Param1 string `protobuf:"bytes,1,opt,name=param1,proto3" json:"param1"`
Param2 string `protobuf:"bytes,2,opt,name=param2,proto3" json:"param2"`
}
func (x *RPCGeneralReqA2) Reset() {
*x = RPCGeneralReqA2{}
if protoimpl.UnsafeEnabled {
mi := &file_comm_proto_msgTypes[19]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RPCGeneralReqA2) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RPCGeneralReqA2) ProtoMessage() {}
func (x *RPCGeneralReqA2) ProtoReflect() protoreflect.Message {
mi := &file_comm_proto_msgTypes[19]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RPCGeneralReqA2.ProtoReflect.Descriptor instead.
func (*RPCGeneralReqA2) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{19}
}
func (x *RPCGeneralReqA2) GetParam1() string {
if x != nil {
return x.Param1
}
return ""
}
func (x *RPCGeneralReqA2) GetParam2() string {
if x != nil {
return x.Param2
}
return ""
}
// rpc 通用请求消息 1
type RPCGeneralReqA3 struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Param1 string `protobuf:"bytes,1,opt,name=param1,proto3" json:"param1"`
Param2 string `protobuf:"bytes,2,opt,name=param2,proto3" json:"param2"`
Param3 string `protobuf:"bytes,3,opt,name=param3,proto3" json:"param3"`
}
func (x *RPCGeneralReqA3) Reset() {
*x = RPCGeneralReqA3{}
if protoimpl.UnsafeEnabled {
mi := &file_comm_proto_msgTypes[20]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RPCGeneralReqA3) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RPCGeneralReqA3) ProtoMessage() {}
func (x *RPCGeneralReqA3) ProtoReflect() protoreflect.Message {
mi := &file_comm_proto_msgTypes[20]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RPCGeneralReqA3.ProtoReflect.Descriptor instead.
func (*RPCGeneralReqA3) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{20}
}
func (x *RPCGeneralReqA3) GetParam1() string {
if x != nil {
return x.Param1
}
return ""
}
func (x *RPCGeneralReqA3) GetParam2() string {
if x != nil {
return x.Param2
}
return ""
}
func (x *RPCGeneralReqA3) GetParam3() string {
if x != nil {
return x.Param3
}
return ""
}
// rpc 通用请求消息 1
type RPCGeneralReqA4 struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Param1 string `protobuf:"bytes,1,opt,name=param1,proto3" json:"param1"`
Param2 string `protobuf:"bytes,2,opt,name=param2,proto3" json:"param2"`
Param3 string `protobuf:"bytes,3,opt,name=param3,proto3" json:"param3"`
Param4 string `protobuf:"bytes,4,opt,name=param4,proto3" json:"param4"`
}
func (x *RPCGeneralReqA4) Reset() {
*x = RPCGeneralReqA4{}
if protoimpl.UnsafeEnabled {
mi := &file_comm_proto_msgTypes[21]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RPCGeneralReqA4) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RPCGeneralReqA4) ProtoMessage() {}
func (x *RPCGeneralReqA4) ProtoReflect() protoreflect.Message {
mi := &file_comm_proto_msgTypes[21]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RPCGeneralReqA4.ProtoReflect.Descriptor instead.
func (*RPCGeneralReqA4) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{21}
}
func (x *RPCGeneralReqA4) GetParam1() string {
if x != nil {
return x.Param1
}
return ""
}
func (x *RPCGeneralReqA4) GetParam2() string {
if x != nil {
return x.Param2
}
return ""
}
func (x *RPCGeneralReqA4) GetParam3() string {
if x != nil {
return x.Param3
}
return ""
}
func (x *RPCGeneralReqA4) GetParam4() string {
if x != nil {
return x.Param4
}
return ""
}
var File_comm_proto protoreflect.FileDescriptor var File_comm_proto protoreflect.FileDescriptor
var file_comm_proto_rawDesc = []byte{ var file_comm_proto_rawDesc = []byte{
@ -1309,12 +1549,32 @@ var file_comm_proto_rawDesc = []byte{
0x64, 0x22, 0x1d, 0x0a, 0x07, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x22, 0x1d, 0x0a, 0x07, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x22, 0x0a, 0x0a, 0x08, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x22, 0x0b, 0x0a, 0x09, 0x22, 0x0a, 0x0a, 0x08, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x22, 0x0b, 0x0a, 0x09,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x2a, 0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x29, 0x0a, 0x0f, 0x52, 0x50, 0x43,
0x6f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x41, 0x31, 0x12, 0x16, 0x0a, 0x06,
0x06, 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61,
0x12, 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x72, 0x61, 0x6d, 0x31, 0x22, 0x41, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x47, 0x65, 0x6e, 0x65, 0x72,
0x65, 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x41, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d,
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x31, 0x12,
0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x32, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x32, 0x22, 0x59, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x47, 0x65,
0x6e, 0x65, 0x72, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x41, 0x33, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61,
0x72, 0x61, 0x6d, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61,
0x6d, 0x31, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x32, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61,
0x72, 0x61, 0x6d, 0x33, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61,
0x6d, 0x33, 0x22, 0x71, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c,
0x52, 0x65, 0x71, 0x41, 0x34, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x31, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x31, 0x12, 0x16, 0x0a,
0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x32, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70,
0x61, 0x72, 0x61, 0x6d, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x33, 0x18,
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x33, 0x12, 0x16, 0x0a,
0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x34, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70,
0x61, 0x72, 0x61, 0x6d, 0x34, 0x2a, 0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x74, 0x74,
0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x48,
0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03,
0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x10, 0x03,
0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -1330,7 +1590,7 @@ func file_comm_proto_rawDescGZIP() []byte {
} }
var file_comm_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_comm_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_comm_proto_msgTypes = make([]protoimpl.MessageInfo, 18) var file_comm_proto_msgTypes = make([]protoimpl.MessageInfo, 22)
var file_comm_proto_goTypes = []interface{}{ var file_comm_proto_goTypes = []interface{}{
(HeroAttributesType)(0), // 0: HeroAttributesType (HeroAttributesType)(0), // 0: HeroAttributesType
(*UserMessage)(nil), // 1: UserMessage (*UserMessage)(nil), // 1: UserMessage
@ -1351,18 +1611,22 @@ var file_comm_proto_goTypes = []interface{}{
(*NameReq)(nil), // 16: NameReq (*NameReq)(nil), // 16: NameReq
(*EmptyReq)(nil), // 17: EmptyReq (*EmptyReq)(nil), // 17: EmptyReq
(*EmptyResp)(nil), // 18: EmptyResp (*EmptyResp)(nil), // 18: EmptyResp
(*anypb.Any)(nil), // 19: google.protobuf.Any (*RPCGeneralReqA1)(nil), // 19: RPCGeneralReqA1
(ErrorCode)(0), // 20: ErrorCode (*RPCGeneralReqA2)(nil), // 20: RPCGeneralReqA2
(*RPCGeneralReqA3)(nil), // 21: RPCGeneralReqA3
(*RPCGeneralReqA4)(nil), // 22: RPCGeneralReqA4
(*anypb.Any)(nil), // 23: google.protobuf.Any
(ErrorCode)(0), // 24: ErrorCode
} }
var file_comm_proto_depIdxs = []int32{ var file_comm_proto_depIdxs = []int32{
19, // 0: UserMessage.data:type_name -> google.protobuf.Any 23, // 0: UserMessage.data:type_name -> google.protobuf.Any
19, // 1: AgentMessage.Message:type_name -> google.protobuf.Any 23, // 1: AgentMessage.Message:type_name -> google.protobuf.Any
20, // 2: RPCMessageReply.Code:type_name -> ErrorCode 24, // 2: RPCMessageReply.Code:type_name -> ErrorCode
19, // 3: RPCMessageReply.ErrorData:type_name -> google.protobuf.Any 23, // 3: RPCMessageReply.ErrorData:type_name -> google.protobuf.Any
1, // 4: RPCMessageReply.Reply:type_name -> UserMessage 1, // 4: RPCMessageReply.Reply:type_name -> UserMessage
1, // 5: AgentSendMessageReq.Reply:type_name -> UserMessage 1, // 5: AgentSendMessageReq.Reply:type_name -> UserMessage
19, // 6: BatchMessageReq.Data:type_name -> google.protobuf.Any 23, // 6: BatchMessageReq.Data:type_name -> google.protobuf.Any
19, // 7: BroadCastMessageReq.Data:type_name -> google.protobuf.Any 23, // 7: BroadCastMessageReq.Data:type_name -> google.protobuf.Any
8, // [8:8] is the sub-list for method output_type 8, // [8:8] is the sub-list for method output_type
8, // [8:8] is the sub-list for method input_type 8, // [8:8] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name 8, // [8:8] is the sub-list for extension type_name
@ -1593,6 +1857,54 @@ func file_comm_proto_init() {
return nil return nil
} }
} }
file_comm_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RPCGeneralReqA1); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_comm_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RPCGeneralReqA2); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_comm_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RPCGeneralReqA3); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_comm_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RPCGeneralReqA4); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -1600,7 +1912,7 @@ func file_comm_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_comm_proto_rawDesc, RawDescriptor: file_comm_proto_rawDesc,
NumEnums: 1, NumEnums: 1,
NumMessages: 18, NumMessages: 22,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -8,6 +8,8 @@ type (
ISys interface { ISys interface {
//本服数据连接 //本服数据连接
Local() (conn *DBConn, err error) Local() (conn *DBConn, err error)
//当前是否是跨服
IsCross() bool
//跨服区服id //跨服区服id
CrossTag() string CrossTag() string
//本服数据连接 //本服数据连接
@ -53,6 +55,10 @@ func Local() (conn *DBConn, err error) {
return defsys.Local() return defsys.Local()
} }
func IsCross() bool {
return defsys.IsCross()
}
func CrossTag() string { func CrossTag() string {
return defsys.CrossTag() return defsys.CrossTag()
} }

View File

@ -106,7 +106,9 @@ func (this *DB) Local() (conn *DBConn, err error) {
} }
return return
} }
func (this *DB) IsCross() bool {
return this.options.IsCross
}
func (this *DB) CrossTag() string { func (this *DB) CrossTag() string {
return this.options.CrossTag return this.options.CrossTag
} }
@ -119,6 +121,7 @@ func (this *DB) Cross() (conn *DBConn, err error) {
return return
} }
func (this *DB) ServerDBConn(stage string) (conn *DBConn, err error) { func (this *DB) ServerDBConn(stage string) (conn *DBConn, err error) {
ok := false ok := false
conn, ok = this.servers[stage] conn, ok = this.servers[stage]
@ -127,6 +130,7 @@ func (this *DB) ServerDBConn(stage string) (conn *DBConn, err error) {
} }
return return
} }
func (this *DB) GetServerTags() []string { func (this *DB) GetServerTags() []string {
keys := make([]string, 0) keys := make([]string, 0)
for k, _ := range this.servers { for k, _ := range this.servers {