上传系统广告需求优化
This commit is contained in:
parent
7f9807f51b
commit
3a73eb07cc
@ -195,7 +195,7 @@ type (
|
||||
//推送消息到用户
|
||||
SendUserChat(msg *pb.DBChat) (code pb.ErrorCode)
|
||||
//广播系统消息
|
||||
SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value int32, agrs ...interface{}) (code pb.ErrorCode)
|
||||
SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value int32, agrs ...string) (code pb.ErrorCode)
|
||||
//广播系统消息
|
||||
SendSysChatToUser(session IUserSession, ctype ChatSystemType, value int32, agrs ...interface{}) (code pb.ErrorCode)
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ func (this *Chat) SendUserChat(msg *pb.DBChat) (code pb.ErrorCode) {
|
||||
}
|
||||
|
||||
//广播系统消息
|
||||
func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value int32, agrs ...interface{}) (code pb.ErrorCode) {
|
||||
func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata interface{}, value int32, agrs ...string) (code pb.ErrorCode) {
|
||||
var (
|
||||
jsonStr []byte
|
||||
err error
|
||||
@ -228,8 +228,10 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter
|
||||
Ctype: pb.ChatType_Text,
|
||||
Stag: this.service.GetTag(),
|
||||
Ctime: configure.Now().Unix(),
|
||||
Content: fmt.Sprintf(st.Text, agrs...),
|
||||
Content: "",
|
||||
Display: st.Display,
|
||||
AppendInt: int64(st.Key),
|
||||
AppendStrs: agrs,
|
||||
}
|
||||
if ctype == comm.EquipmentUpgradeNotice { //装备分享
|
||||
msg.Ctype = pb.ChatType_Share
|
||||
@ -238,8 +240,8 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter
|
||||
this.Errorf("err:%v", err)
|
||||
} else {
|
||||
data := map[string]interface{}{
|
||||
agrs[1].(string): map[string]interface{}{
|
||||
"key": agrs[1].(string),
|
||||
agrs[1]: map[string]interface{}{
|
||||
"key": agrs[1],
|
||||
"appendStr": string(jsonStr),
|
||||
"itemType": pb.ChatType_EquipmentShare,
|
||||
},
|
||||
|
@ -2,7 +2,6 @@ package equipment
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
@ -190,7 +189,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user != nil {
|
||||
// var color *cfg.GameGameColorData
|
||||
// if color, err = this.module.configure.GetColor(conf.Color); err == nil {
|
||||
this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment, equipment.Lv, user.Name, fmt.Sprintf("[%s]", conf.Name))
|
||||
this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment, equipment.Lv, user.Name, conf.Id)
|
||||
// } else {
|
||||
// this.module.Errorf("GetColor err:%s", err.Error())
|
||||
// }
|
||||
|
@ -68,7 +68,7 @@ func (this *ChatComp) Start() (err error) {
|
||||
|
||||
cronStr := fmt.Sprintf("0 %d %d ? * %s", v1.TimeM, v1.TimeH, weekStr)
|
||||
this.module.Debug("注册Chat广播公告消息", log.Fields{"cronStr": cronStr, "text": v1.Text})
|
||||
if id, err = cron.AddFunc(cronStr, this.chatNoticen(v1.Text)); err != nil {
|
||||
if id, err = cron.AddFunc(cronStr, this.chatNoticen(v1)); err != nil {
|
||||
this.module.Errorf("cron.AddFunc:%s err:%v", cronStr, err)
|
||||
continue
|
||||
}
|
||||
@ -80,16 +80,18 @@ func (this *ChatComp) Start() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ChatComp) chatNoticen(content string) func() {
|
||||
func (this *ChatComp) chatNoticen(sys *cfg.GameChatSystemData) func() {
|
||||
return func() {
|
||||
msg := &pb.DBChat{
|
||||
Channel: pb.ChatChannel_System,
|
||||
Stag: this.service.GetTag(),
|
||||
Ctime: configure.Now().Unix(),
|
||||
Content: content,
|
||||
Content: "",
|
||||
Display: sys.Display,
|
||||
AppendInt: int64(sys.Key),
|
||||
}
|
||||
data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})
|
||||
this.module.Debug("广播公告消息", log.Fields{"chat": content})
|
||||
this.module.Debug("广播公告消息", log.Fields{"chat": sys.Text})
|
||||
if err := this.module.service.RpcBroadcast(context.Background(), comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{
|
||||
MainType: string(comm.ModuleChat),
|
||||
SubType: "message",
|
||||
|
Loading…
Reference in New Issue
Block a user