上传工会boos战代码

This commit is contained in:
liwei 2023-07-19 18:11:40 +08:00
parent fb084e55d9
commit 8f84a12855
7 changed files with 57 additions and 43 deletions

View File

@ -20,13 +20,13 @@ var unionchatkey = "chat:union"
var crosschatkey = "chat:cross"
var systemchatkey = "chat:system"
///论坛 数据组件
// /论坛 数据组件
type modelChatComp struct {
modules.MCompModel
module *Chat
}
//组件初始化接口
// 组件初始化接口
func (this *modelChatComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
this.TableName = comm.TableChat
this.MCompModel.Init(service, module, comp, opt)
@ -38,7 +38,7 @@ func (this *modelChatComp) Init(service core.IService, module core.IModule, comp
return
}
//查询用户未读消息
// 查询用户未读消息
func (this *modelChatComp) queryUserMsg(uid string) (result []*pb.DBChat, err error) {
var (
c *mongo.Cursor
@ -62,7 +62,7 @@ func (this *modelChatComp) queryUserMsg(uid string) (result []*pb.DBChat, err er
return
}
//查询用户未读消息
// 查询用户未读消息
func (this *modelChatComp) getChatQueue(channel pb.ChatChannel, stag, union string, area int32) (result []*pb.DBChat, err error) {
var (
key string
@ -123,7 +123,7 @@ func (this *modelChatComp) getChatQueue(channel pb.ChatChannel, stag, union stri
return
}
//添加跨服频道成员
// 添加跨服频道成员
func (this *modelChatComp) addCrossChannelMember(session comm.IUserSession) (channel int32, err error) {
udata := &pb.CacheUser{
Uid: session.GetUserId(),
@ -159,7 +159,7 @@ func (this *modelChatComp) addCrossChannelMember(session comm.IUserSession) (cha
return
}
//切换跨服频道
// 切换跨服频道
func (this *modelChatComp) chanageChannel(session comm.IUserSession, channel int32) (err error, ok bool) {
udata := &pb.CacheUser{
Uid: session.GetUserId(),
@ -190,7 +190,7 @@ func (this *modelChatComp) chanageChannel(session comm.IUserSession, channel int
return
}
//读取跨服聊天频道下成员
// 读取跨服聊天频道下成员
func (this *modelChatComp) getCrossChannelMember(channel int32) (result []*pb.CacheUser, err error) {
key := fmt.Sprintf("%s-%d-member", crosschatkey, channel)
temp := make(map[string]*pb.CacheUser, 0)
@ -207,7 +207,7 @@ func (this *modelChatComp) getCrossChannelMember(channel int32) (result []*pb.Ca
return
}
//移除频道成员
// 移除频道成员
func (this *modelChatComp) removeCrossChannelMember(uid string) (err error) {
var (
result *pb.DBUserExpand
@ -225,7 +225,7 @@ func (this *modelChatComp) removeCrossChannelMember(uid string) (err error) {
return
}
//保存用户聊天消息
// 保存用户聊天消息
func (this *modelChatComp) saveUserMsg(msg *pb.DBChat) (err error) {
if _, err = this.DB.InsertOne(core.SqlTable(this.TableName), msg); err != nil {
this.module.Errorf("err:%v", err)
@ -320,7 +320,7 @@ func (this *modelChatComp) addChatMsg(key string, count int64, msgs ...*pb.DBCha
return
}
//发送聊天消息到世界频道
// 发送聊天消息到世界频道
func (this *modelChatComp) sendChatToWorld(chat *pb.DBChat, queuecount int32) (err error) {
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", worldchatkey, chat.Stag), int64(queuecount), chat); err != nil {
this.module.Errorln(err)
@ -333,20 +333,28 @@ func (this *modelChatComp) sendChatToWorld(chat *pb.DBChat, queuecount int32) (e
return
}
//发送聊天消息到工会频道
func (this *modelChatComp) sendChatToUnion(chat *pb.DBChat, queuecount int32) (err error) {
// 发送聊天消息到工会频道
func (this *modelChatComp) sendChatToUnion(chat *pb.DBChat, queuecount int32) (errdata *pb.ErrorData) {
var (
err error
)
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", unionchatkey, chat.UnionId), int64(queuecount), chat); err != nil {
this.module.Errorln(err)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
if err = this.module.pushChatToUnion(chat); err != nil {
this.module.Errorln(err)
if errdata = this.module.pushChatToUnion(chat); errdata != nil {
this.module.Errorln(errdata)
return
}
return
}
//发送聊天消息到工会频道
// 发送聊天消息到工会频道
func (this *modelChatComp) sendChatToCrossServer(chat *pb.DBChat, queuecount int32) (err error) {
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%d", crosschatkey, chat.ChannelId), int64(queuecount), chat); err != nil {
this.module.Errorln(err)
@ -358,7 +366,7 @@ func (this *modelChatComp) sendChatToCrossServer(chat *pb.DBChat, queuecount int
return
}
//发送聊天消息到私聊频道
// 发送聊天消息到私聊频道
func (this *modelChatComp) sendChatToSystem(chat *pb.DBChat) (err error) {
if err = this.module.pushChatToSystem(chat); err != nil {
this.module.Errorln(err)
@ -367,7 +375,7 @@ func (this *modelChatComp) sendChatToSystem(chat *pb.DBChat) (err error) {
return
}
//发送聊天消息到私聊频道
// 发送聊天消息到私聊频道
func (this *modelChatComp) sendChatToPrivate(chat *pb.DBChat) (err error) {
if err = this.module.pushChatToPrivate(chat); err != nil {
this.module.Errorln(err)

View File

@ -2,6 +2,7 @@ package chat
import (
"context"
"errors"
"go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
@ -93,6 +94,7 @@ func (this *Chat) EventUserOffline(uid, sessionid string) {
func (this *Chat) Rpc_ModuleChatPushChat(ctx context.Context, args *pb.DBChat, reply *pb.EmptyResp) (err error) {
var (
max_chat int32
errdata *pb.ErrorData
)
if max_chat, err = this.configure.GetChannelRecordMax(); err != nil {
this.Errorln(err)
@ -106,7 +108,8 @@ func (this *Chat) Rpc_ModuleChatPushChat(ctx context.Context, args *pb.DBChat, r
}
break
case pb.ChatChannel_Union:
if err = this.modelChat.sendChatToUnion(args, max_chat); err != nil {
if errdata = this.modelChat.sendChatToUnion(args, max_chat); errdata != nil {
err = errors.New(errdata.Message)
this.Errorln(err)
return
}
@ -189,8 +192,8 @@ func (this *Chat) SendUnionChat(msg *pb.DBChat) (errdata *pb.ErrorData) {
return
}
if this.IsCross() {
if err = this.modelChat.sendChatToUnion(msg, max_chat); err != nil {
this.Errorln(err)
if errdata = this.modelChat.sendChatToUnion(msg, max_chat); errdata != nil {
this.Errorln(errdata)
return
}
} else {
@ -353,8 +356,11 @@ func (this *Chat) pushChatToWorld(msg *pb.DBChat) (err error) {
}
// 推送消息到工会
func (this *Chat) pushChatToUnion(msg *pb.DBChat) (err error) {
if members := this.sociaty.MembersBySociatyId(msg.UnionId); members != nil {
func (this *Chat) pushChatToUnion(msg *pb.DBChat) (errdata *pb.ErrorData) {
var (
members []*pb.SociatyMemberInfo
)
if members, errdata = this.sociaty.MembersBySociatyId(msg.UnionId); members != nil {
users := make([]string, 0, len(members))
for _, v := range members {
if v.OfflineTime == 0 { //离线时间为0 表示在线

View File

@ -10,13 +10,13 @@ import (
)
// 参数校验
func (this *apiComp) ChallengeFinishCheck(session comm.IUserSession, req *pb.UniongveChallengeFinishRep) (errdata *pb.ErrorData) {
func (this *apiComp) ChallengeFinishCheck(session comm.IUserSession, req *pb.UniongveChallengeFinishReq) (errdata *pb.ErrorData) {
return
}
// 获取工会boos战信息
func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.UniongveChallengeFinishRep) (errdata *pb.ErrorData) {
func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.UniongveChallengeFinishReq) (errdata *pb.ErrorData) {
var (
conf *cfg.GameGuildBossData
score *cfg.GameGuildBossScoreData

View File

@ -98,5 +98,5 @@ func (this *ModelUnionroulette) roulettechangePush(unionid string, uid string, a
this.module.SendMsgToUsers(string(this.module.GetType()), "roulettechange", &pb.UniongveRouletteChangePush{
Record: info,
})
}, users...)
}

View File

@ -189,7 +189,7 @@ func (this *ModelUniongve) booshpchangepush(unionid string, info *pb.DBUnionGve)
}
this.module.SendMsgToUsers(string(this.module.GetType()), "booschange", &pb.UniongveBoosChangePush{
Info: info,
})
}, users...)
}
// 击杀boos
@ -247,7 +247,7 @@ func (this *ModelUniongve) booskill(unionid string, boosid int32, info *pb.DBUni
}
this.module.SendMsgToUsers(string(this.module.GetType()), "stagechange", &pb.UniongveStageChangePush{
Info: info,
})
}, users...)
}
// boos 信息变化推送

View File

@ -116,7 +116,7 @@ func (this *modelRank) raceSettlement() {
}
// boos 血量变化推送
// boos 奖励推送
func (this *modelRank) rankRewardPush(unionid string, reward []*cfg.Gameatn) {
var (
members []*pb.SociatyMemberInfo

View File

@ -611,7 +611,7 @@ func (x *UniongveChallengeResp) GetInfo() *BattleInfo {
}
//战斗 完成请求
type UniongveChallengeFinishRep struct {
type UniongveChallengeFinishReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
@ -621,8 +621,8 @@ type UniongveChallengeFinishRep struct {
Report *BattleReport `protobuf:"bytes,3,opt,name=report,proto3" json:"report"` //战报
}
func (x *UniongveChallengeFinishRep) Reset() {
*x = UniongveChallengeFinishRep{}
func (x *UniongveChallengeFinishReq) Reset() {
*x = UniongveChallengeFinishReq{}
if protoimpl.UnsafeEnabled {
mi := &file_uniongve_uniongve_msg_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -630,13 +630,13 @@ func (x *UniongveChallengeFinishRep) Reset() {
}
}
func (x *UniongveChallengeFinishRep) String() string {
func (x *UniongveChallengeFinishReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UniongveChallengeFinishRep) ProtoMessage() {}
func (*UniongveChallengeFinishReq) ProtoMessage() {}
func (x *UniongveChallengeFinishRep) ProtoReflect() protoreflect.Message {
func (x *UniongveChallengeFinishReq) ProtoReflect() protoreflect.Message {
mi := &file_uniongve_uniongve_msg_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -648,26 +648,26 @@ func (x *UniongveChallengeFinishRep) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use UniongveChallengeFinishRep.ProtoReflect.Descriptor instead.
func (*UniongveChallengeFinishRep) Descriptor() ([]byte, []int) {
// Deprecated: Use UniongveChallengeFinishReq.ProtoReflect.Descriptor instead.
func (*UniongveChallengeFinishReq) Descriptor() ([]byte, []int) {
return file_uniongve_uniongve_msg_proto_rawDescGZIP(), []int{11}
}
func (x *UniongveChallengeFinishRep) GetUnionid() string {
func (x *UniongveChallengeFinishReq) GetUnionid() string {
if x != nil {
return x.Unionid
}
return ""
}
func (x *UniongveChallengeFinishRep) GetBoosid() int32 {
func (x *UniongveChallengeFinishReq) GetBoosid() int32 {
if x != nil {
return x.Boosid
}
return 0
}
func (x *UniongveChallengeFinishRep) GetReport() *BattleReport {
func (x *UniongveChallengeFinishReq) GetReport() *BattleReport {
if x != nil {
return x.Report
}
@ -996,7 +996,7 @@ var file_uniongve_uniongve_msg_proto_rawDesc = []byte{
0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69,
0x6e, 0x66, 0x6f, 0x22, 0x75, 0x0a, 0x1a, 0x55, 0x6e, 0x69, 0x6f, 0x6e, 0x67, 0x76, 0x65, 0x43,
0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65,
0x70, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x71, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x62,
0x6f, 0x6f, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x6f, 0x6f,
0x73, 0x69, 0x64, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20,
@ -1055,7 +1055,7 @@ var file_uniongve_uniongve_msg_proto_goTypes = []interface{}{
(*UniongveRouletteResp)(nil), // 8: UniongveRouletteResp
(*UniongveChallengeReq)(nil), // 9: UniongveChallengeReq
(*UniongveChallengeResp)(nil), // 10: UniongveChallengeResp
(*UniongveChallengeFinishRep)(nil), // 11: UniongveChallengeFinishRep
(*UniongveChallengeFinishReq)(nil), // 11: UniongveChallengeFinishReq
(*UniongveChallengeFinishResp)(nil), // 12: UniongveChallengeFinishResp
(*UniongveInfoChangePush)(nil), // 13: UniongveInfoChangePush
(*UniongveStageChangePush)(nil), // 14: UniongveStageChangePush
@ -1074,7 +1074,7 @@ var file_uniongve_uniongve_msg_proto_depIdxs = []int32{
18, // 2: UniongveRouletteResp.award:type_name -> UserAssets
19, // 3: UniongveChallengeReq.battle:type_name -> BattleFormation
20, // 4: UniongveChallengeResp.info:type_name -> BattleInfo
21, // 5: UniongveChallengeFinishRep.report:type_name -> BattleReport
21, // 5: UniongveChallengeFinishReq.report:type_name -> BattleReport
18, // 6: UniongveChallengeFinishResp.award:type_name -> UserAssets
17, // 7: UniongveInfoChangePush.info:type_name -> DBUnionGve
17, // 8: UniongveStageChangePush.info:type_name -> DBUnionGve
@ -1229,7 +1229,7 @@ func file_uniongve_uniongve_msg_proto_init() {
}
}
file_uniongve_uniongve_msg_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UniongveChallengeFinishRep); i {
switch v := v.(*UniongveChallengeFinishReq); i {
case 0:
return &v.state
case 1: