1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package logic
- import (
- "context"
- "github.com/bytedance/sonic"
- "time"
- "ylink/comm/model"
- "ylink/core/cmd/rpc/internal/svc"
- "ylink/core/cmd/rpc/pb"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type PlayerSendMsgLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewPlayerSendMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PlayerSendMsgLogic {
- return &PlayerSendMsgLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- func (l *PlayerSendMsgLogic) PlayerSendMsg(in *pb.PlayerSendMsgReq) (*pb.PlayerSendMsgResp, error) {
- // 投递到自己的发件箱
- message := &model.KqMessage{
- CreateTime: time.Now().Format("2006-01-02 15:04:05"),
- Content: in.Content,
- Pic: in.Pic,
- SenderId: in.GameId + "_" + in.PlayerId,
- GameId: in.GameId,
- Uid: in.PlayerId,
- }
- kMsg, _ := sonic.MarshalString(message)
- _, _, err := l.svcCtx.KqMsgBoxProducer.SendMessage(l.ctx, kMsg, message.SenderId)
- if err != nil {
- return nil, err
- }
- return &pb.PlayerSendMsgResp{}, nil
- }
|