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) SpanSendCheck(session comm.IUserSession, req *pb.ChatSpanSendReq) (code pb.ErrorCode) { return } ///跨越服务消息请求 func (this *apiComp) SpanSend(session comm.IUserSession, req *pb.ChatSpanSendReq) (code pb.ErrorCode, data proto.Message) { var ( err error msg *pb.DBChat user *pb.DBUser userexpand *pb.DBUserExpand group int32 max_chat int32 ) if userexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil { code = pb.ErrorCode_DBError return } msg = &pb.DBChat{ Id: primitive.NewObjectID().Hex(), Channel: req.Channel, Suid: session.GetUserId(), AreaId: userexpand.Chatchannel, Avatar: user.Avatar, Content: req.Content, Ctime: time.Now().Unix(), } if group, err = this.module.configure.GetServiecTagGroup(session.GetServiecTag()); err != nil { code = pb.ErrorCode_ConfigNoFound return } if max_chat, err = this.module.configure.GetChannelRecordMax(); err != nil { return } switch msg.Channel { case pb.ChatChannel_CrossServer: if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s:%d--%d", crosschatkey, group, userexpand.Chatchannel), int64(max_chat), msg); err != nil { code = pb.ErrorCode_DBError return } this.module.PushToUsers(group, userexpand.Chatchannel, msg) break } session.SendMsg(string(this.module.GetType()), "spansend", &pb.ChatSendResp{}) return }