上传聊天公告附加数据
This commit is contained in:
parent
0bac28f7fd
commit
11f99c0dc0
@ -143,7 +143,7 @@ type (
|
||||
//推送消息到用户
|
||||
SendUserChat(msg *pb.DBChat) (code pb.ErrorCode)
|
||||
//广播系统消息
|
||||
SendSysChatToWorld(ctype ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode)
|
||||
SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value int32, agrs ...interface{}) (code pb.ErrorCode)
|
||||
//广播系统消息
|
||||
SendSysChatToUser(session IUserSession, ctype ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/utils/codec/json"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"time"
|
||||
@ -93,14 +94,29 @@ func (this *Chat) SendUserChat(msg *pb.DBChat) (code pb.ErrorCode) {
|
||||
}
|
||||
|
||||
//广播系统消息
|
||||
func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode) {
|
||||
func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value int32, agrs ...interface{}) (code pb.ErrorCode) {
|
||||
var (
|
||||
jsonStr []byte
|
||||
err error
|
||||
)
|
||||
if st, ok := this.configure.GetCheckChatSystem(int32(ctype), value); ok {
|
||||
msg := &pb.DBChat{
|
||||
Channel: pb.ChatChannel_System,
|
||||
Ctype: pb.ChatType_Text,
|
||||
Stag: this.service.GetTag(),
|
||||
Ctime: time.Now().Unix(),
|
||||
Content: fmt.Sprintf(st.Text, agrs...),
|
||||
}
|
||||
if ctype == comm.EquipmentUpgradeNotice { //装备分享
|
||||
msg.Ctype = pb.ChatType_EquipmentShare
|
||||
}
|
||||
if appenddata != nil {
|
||||
if jsonStr, err = json.Marshal(appenddata); err != nil {
|
||||
this.Errorf("err:%v", err)
|
||||
} else {
|
||||
msg.AppendStr = string(jsonStr)
|
||||
}
|
||||
}
|
||||
code = this.modelChat.sendSystemChat(msg)
|
||||
}
|
||||
return
|
||||
|
@ -172,7 +172,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype47, 1)
|
||||
//聊天系统通知
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user != nil {
|
||||
this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment.Lv, user.Name, conf.Name)
|
||||
this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment, equipment.Lv, user.Name, conf.Name)
|
||||
} else {
|
||||
this.module.Errorf("no found userdata uid:%s", session.GetUserId())
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal
|
||||
session.SendMsg(string(this.module.GetType()), PagodaChallengeOverResp, &pb.PagodaChallengeOverResp{Data: pagoda})
|
||||
|
||||
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil {
|
||||
this.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, pagoda.PagodaId, user.Name)
|
||||
this.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, nil, pagoda.PagodaId, user.Name)
|
||||
} else {
|
||||
this.module.Errorf("no found userdata uid:%s", session.GetUserId())
|
||||
}
|
||||
|
@ -79,8 +79,10 @@ func (ChatChannel) EnumDescriptor() ([]byte, []int) {
|
||||
type ChatType int32
|
||||
|
||||
const (
|
||||
ChatType_Text ChatType = 0 //文泵聊天消息
|
||||
ChatType_Moonfantasy ChatType = 1 //月子秘境消息
|
||||
ChatType_Text ChatType = 0 //文泵聊天消息
|
||||
ChatType_Moonfantasy ChatType = 1 //月子秘境消息
|
||||
ChatType_HeroShare ChatType = 2 //英雄分享
|
||||
ChatType_EquipmentShare ChatType = 3 //装备分享
|
||||
)
|
||||
|
||||
// Enum value maps for ChatType.
|
||||
@ -88,10 +90,14 @@ var (
|
||||
ChatType_name = map[int32]string{
|
||||
0: "Text",
|
||||
1: "Moonfantasy",
|
||||
2: "HeroShare",
|
||||
3: "EquipmentShare",
|
||||
}
|
||||
ChatType_value = map[string]int32{
|
||||
"Text": 0,
|
||||
"Moonfantasy": 1,
|
||||
"Text": 0,
|
||||
"Moonfantasy": 1,
|
||||
"HeroShare": 2,
|
||||
"EquipmentShare": 3,
|
||||
}
|
||||
)
|
||||
|
||||
@ -324,10 +330,13 @@ var file_chat_chat_db_proto_rawDesc = []byte{
|
||||
0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x6e, 0x69, 0x6f, 0x6e, 0x10, 0x01, 0x12, 0x0b, 0x0a,
|
||||
0x07, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x72,
|
||||
0x6f, 0x73, 0x73, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x53,
|
||||
0x79, 0x73, 0x74, 0x65, 0x6d, 0x10, 0x04, 0x2a, 0x25, 0x0a, 0x08, 0x43, 0x68, 0x61, 0x74, 0x54,
|
||||
0x79, 0x73, 0x74, 0x65, 0x6d, 0x10, 0x04, 0x2a, 0x48, 0x0a, 0x08, 0x43, 0x68, 0x61, 0x74, 0x54,
|
||||
0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x65, 0x78, 0x74, 0x10, 0x00, 0x12, 0x0f, 0x0a,
|
||||
0x0b, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x10, 0x01, 0x42, 0x06,
|
||||
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x0b, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x10, 0x01, 0x12, 0x0d,
|
||||
0x0a, 0x09, 0x48, 0x65, 0x72, 0x6f, 0x53, 0x68, 0x61, 0x72, 0x65, 0x10, 0x02, 0x12, 0x12, 0x0a,
|
||||
0x0e, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x68, 0x61, 0x72, 0x65, 0x10,
|
||||
0x03, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
Loading…
Reference in New Issue
Block a user