上传月子秘境 对接聊天系统推送好友消息
This commit is contained in:
parent
d975c28b68
commit
c4890b796b
@ -121,4 +121,10 @@ type (
|
|||||||
// 重置点赞列表和每日友情点
|
// 重置点赞列表和每日友情点
|
||||||
ResetFriend(uid string)
|
ResetFriend(uid string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//聊天系统
|
||||||
|
IChat interface {
|
||||||
|
//推送消息到用户
|
||||||
|
PushUser(msg *pb.DBChat) (err error)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
@ -23,6 +23,7 @@ func (this *apiComp) Trigger(session comm.IUserSession, req *pb.MoonfantasyTrigg
|
|||||||
uexpand *pb.DBUserExpand
|
uexpand *pb.DBUserExpand
|
||||||
boss *cfg.GameDreamlandBoosData
|
boss *cfg.GameDreamlandBoosData
|
||||||
mdata *pb.DBMoonfantasy
|
mdata *pb.DBMoonfantasy
|
||||||
|
chat *pb.DBChat
|
||||||
issucc bool
|
issucc bool
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
@ -64,6 +65,16 @@ func (this *apiComp) Trigger(session comm.IUserSession, req *pb.MoonfantasyTrigg
|
|||||||
"moonfantasyTriggerNum": uexpand.MoonfantasyTriggerNum + 1,
|
"moonfantasyTriggerNum": uexpand.MoonfantasyTriggerNum + 1,
|
||||||
"moonfantasyLastTrigger": time.Now().Unix(),
|
"moonfantasyLastTrigger": time.Now().Unix(),
|
||||||
})
|
})
|
||||||
|
chat = &pb.DBChat{
|
||||||
|
Ctype: pb.ChatType_Moonfantasy,
|
||||||
|
Suid: session.GetUserId(),
|
||||||
|
Avatar: req.Avatar,
|
||||||
|
Uname: req.Uname,
|
||||||
|
Slv: req.Ulv,
|
||||||
|
AppendInt: int64(mdata.Monster),
|
||||||
|
AppendStr: mdata.Id,
|
||||||
|
}
|
||||||
|
this.module.modelDream.noticeuserfriend(session.GetServiecTag(), session.GetUserId(), chat)
|
||||||
session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster})
|
session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster})
|
||||||
} else {
|
} else {
|
||||||
session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: false})
|
session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: false})
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"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"
|
||||||
@ -57,3 +58,21 @@ func (this *modelDreamComp) addDreamData(uid string, boss *cfg.GameDreamlandBoos
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///查询好友数据
|
||||||
|
func (this *modelDreamComp) noticeuserfriend(stag, uid string, chat *pb.DBChat) (err error) {
|
||||||
|
model := db.NewDBModel(comm.TableFriend, 0, db.ServerDBConn(stag))
|
||||||
|
friend := &pb.DBFriend{Uid: uid}
|
||||||
|
if err = model.Get(uid, friend); err != nil {
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range friend.FriendIds {
|
||||||
|
temp := *chat
|
||||||
|
temp.Id = primitive.NewObjectID().Hex()
|
||||||
|
temp.Channel = pb.ChatChannel_Private
|
||||||
|
temp.Ruid = v
|
||||||
|
this.module.chat.PushUser(&temp)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@ package moonfantasy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/base"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
)
|
)
|
||||||
@ -18,6 +19,8 @@ func NewModule() core.IModule {
|
|||||||
|
|
||||||
type Moonfantasy struct {
|
type Moonfantasy struct {
|
||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
|
service base.IRPCXService
|
||||||
|
chat comm.IChat
|
||||||
api_comp *apiComp
|
api_comp *apiComp
|
||||||
configure *configureComp
|
configure *configureComp
|
||||||
modelDream *modelDreamComp
|
modelDream *modelDreamComp
|
||||||
@ -31,6 +34,17 @@ func (this *Moonfantasy) GetType() core.M_Modules {
|
|||||||
//模块初始化接口 注册用户创建角色事件
|
//模块初始化接口 注册用户创建角色事件
|
||||||
func (this *Moonfantasy) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
func (this *Moonfantasy) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||||
err = this.ModuleBase.Init(service, module, options)
|
err = this.ModuleBase.Init(service, module, options)
|
||||||
|
this.service = service.(base.IRPCXService)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Moonfantasy) Start() (err error) {
|
||||||
|
err = this.ModuleBase.Start()
|
||||||
|
var module core.IModule
|
||||||
|
if module, err = this.service.GetModule(comm.ModuleChat); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.chat = module.(comm.IChat)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,10 @@ type MoonfantasyTriggerReq struct {
|
|||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Avatar string `protobuf:"bytes,1,opt,name=avatar,proto3" json:"avatar"` //用户头像
|
||||||
|
Uname string `protobuf:"bytes,2,opt,name=uname,proto3" json:"uname"` //用户名
|
||||||
|
Ulv int32 `protobuf:"varint,3,opt,name=ulv,proto3" json:"ulv"` //用户等级
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *MoonfantasyTriggerReq) Reset() {
|
func (x *MoonfantasyTriggerReq) Reset() {
|
||||||
@ -59,6 +63,27 @@ func (*MoonfantasyTriggerReq) Descriptor() ([]byte, []int) {
|
|||||||
return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{0}
|
return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *MoonfantasyTriggerReq) GetAvatar() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Avatar
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *MoonfantasyTriggerReq) GetUname() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Uname
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *MoonfantasyTriggerReq) GetUlv() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Ulv
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
///触发秘境
|
///触发秘境
|
||||||
type MoonfantasyTriggerResp struct {
|
type MoonfantasyTriggerResp struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -231,8 +256,12 @@ var File_moonfantasy_moonfantasy_msg_proto protoreflect.FileDescriptor
|
|||||||
var file_moonfantasy_moonfantasy_msg_proto_rawDesc = []byte{
|
var file_moonfantasy_moonfantasy_msg_proto_rawDesc = []byte{
|
||||||
0x0a, 0x21, 0x6d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2f, 0x6d, 0x6f,
|
0x0a, 0x21, 0x6d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2f, 0x6d, 0x6f,
|
||||||
0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72,
|
0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72,
|
||||||
0x6f, 0x74, 0x6f, 0x22, 0x17, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61,
|
0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61,
|
||||||
0x73, 0x79, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x22, 0x5c, 0x0a, 0x16,
|
0x73, 0x79, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06,
|
||||||
|
0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76,
|
||||||
|
0x61, 0x74, 0x61, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
|
||||||
|
0x01, 0x28, 0x09, 0x52, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x6c,
|
||||||
|
0x76, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x75, 0x6c, 0x76, 0x22, 0x5c, 0x0a, 0x16,
|
||||||
0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x54, 0x72, 0x69, 0x67, 0x67,
|
0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x54, 0x72, 0x69, 0x67, 0x67,
|
||||||
0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63,
|
0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x12, 0x10,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x12, 0x10,
|
||||||
|
Loading…
Reference in New Issue
Block a user