go_dreamfactory/modules/chat/__api_send.go
2022-10-19 14:19:23 +08:00

117 lines
3.7 KiB
Go

package chat
// import (
// "fmt"
// "go_dreamfactory/comm"
// "go_dreamfactory/pb"
// "time"
// "go.mongodb.org/mongo-driver/bson/primitive"
// "google.golang.org/protobuf/proto"
// )
// //参数校验
// func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.ChatSendReq) (code pb.ErrorCode) {
// if (req.Channel == pb.ChatChannel_Union && req.TargetId == "") || (req.Channel == pb.ChatChannel_Private && req.TargetId == "") {
// code = pb.ErrorCode_ReqParameterError
// }
// return
// }
// ///消息发送请求
// func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code pb.ErrorCode, data proto.Message) {
// var (
// err error
// max int32
// msg *pb.DBChat
// // userexpand *pb.DBUserExpand
// max_chat int32
// )
// if code = this.SendCheck(session, req); code != pb.ErrorCode_Success {
// return
// }
// msg = &pb.DBChat{
// Id: primitive.NewObjectID().Hex(),
// Channel: req.Channel,
// Suid: session.GetUserId(),
// Slv: req.Ulv,
// Uname: req.Uname,
// Avatar: req.Avatar,
// Stag: session.GetServiecTag(),
// Ctype: req.Ctype,
// Content: req.Content,
// Ctime: time.Now().Unix(),
// AppendInt: req.AppendInt,
// AppendStr: req.AppendStr,
// AppendBool: req.AppendBool,
// AppendBytes: req.AppendBytes,
// }
// if max, err = this.module.configure.GetChannelRecordMax(); err != nil {
// code = pb.ErrorCode_ConfigNoFound
// return
// }
// if max_chat, err = this.module.configure.GetChannelRecordMax(); err != nil {
// code = pb.ErrorCode_ConfigNoFound
// return
// }
// switch msg.Channel {
// case pb.ChatChannel_World:
// if this.module.options.GM { //判断gm命令
// if code = this.module.gm.CreateCmd(session, req.Content); code == pb.ErrorCode_Success {
// session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{Issucc: true})
// return
// }
// code = pb.ErrorCode_Success
// }
// if err = this.module.modelChat.addChatMsg(worldchatkey, int64(max), msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// if err = this.module.PushWorld(msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// //随机任务
// this.module.ModuleRtask.SendToRtask(session, comm.Rtype62, 1)
// break
// case pb.ChatChannel_Union:
// msg.UnionId = req.TargetId
// if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s:%s", unionchatkey, req.TargetId), int64(max_chat), msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// if err = this.module.PushUnion(req.TargetId, msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// break
// case pb.ChatChannel_Private:
// msg.Ruid = req.TargetId
// if err = this.module.PushUser(msg); err != nil {
// code = pb.ErrorCode_DBError
// return
// }
// session.SendMsg(string(this.module.GetType()), "message", &pb.ChatMessagePush{Chat: msg})
// break
// // case pb.ChatChannel_CrossServer:
// // if userexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
// // code = pb.ErrorCode_DBError
// // return
// // }
// // msg.ChannelId = userexpand.Chatchannel //指定频道
// // if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%d", crosschatkey, userexpand.Chatchannel), int64(max_chat), msg); err != nil {
// // code = pb.ErrorCode_DBError
// // return
// // }
// // this.module.PushToUsers(userexpand.Chatchannel, msg)
// default:
// code = pb.ErrorCode_ReqParameterError
// this.module.Errorf("getlist no support channel:%d ", req.Channel)
// return
// }
// session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{Issucc: true})
// return
// }