mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
ws send msg modify
This commit is contained in:
parent
6bc69d5a75
commit
7416fa3a4c
@ -61,7 +61,7 @@ func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
ContentType: params.ContentType,
|
||||
Content: []byte(newContent),
|
||||
ForceList: params.ForceList,
|
||||
CreateTime: utils.GetCurrentTimestampByNano(),
|
||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||
Options: options,
|
||||
OfflinePushInfo: params.OfflinePushInfo,
|
||||
},
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/gob"
|
||||
@ -51,14 +50,13 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
|
||||
switch m.ReqIdentifier {
|
||||
case constant.WSGetNewestSeq:
|
||||
go ws.getSeqReq(conn, &m)
|
||||
ws.getSeqReq(conn, &m)
|
||||
case constant.WSPullMsg:
|
||||
go ws.pullMsgReq(conn, &m)
|
||||
ws.pullMsgReq(conn, &m)
|
||||
case constant.WSSendMsg:
|
||||
sendTime := utils.GetCurrentTimestampByNano()
|
||||
go ws.sendMsgReq(conn, &m, sendTime)
|
||||
ws.sendMsgReq(conn, &m)
|
||||
case constant.WSPullMsgBySeqList:
|
||||
go ws.pullMsgBySeqListReq(conn, &m)
|
||||
ws.pullMsgBySeqListReq(conn, &m)
|
||||
default:
|
||||
}
|
||||
log.NewInfo("", "goroutine num is ", runtime.NumGoroutine())
|
||||
@ -229,13 +227,12 @@ func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullM
|
||||
ws.sendMsg(conn, mReply)
|
||||
|
||||
}
|
||||
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req, sendTime int64) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, sendTime)
|
||||
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID)
|
||||
nReply := new(pbChat.SendMsgResp)
|
||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg)
|
||||
if isPass {
|
||||
data := pData.(sdk_ws.MsgData)
|
||||
data.SendTime = sendTime
|
||||
pbData := pbChat.SendMsgReq{
|
||||
Token: m.Token,
|
||||
OperationID: m.OperationID,
|
||||
@ -249,26 +246,26 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req, sendTime int64) {
|
||||
log.NewError(pbData.OperationID, "UserSendMsg err", err.Error())
|
||||
nReply.ErrCode = 200
|
||||
nReply.ErrMsg = err.Error()
|
||||
ws.sendMsgResp(conn, m, nReply, sendTime)
|
||||
ws.sendMsgResp(conn, m, nReply)
|
||||
} else {
|
||||
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
|
||||
ws.sendMsgResp(conn, m, reply, sendTime)
|
||||
ws.sendMsgResp(conn, m, reply)
|
||||
}
|
||||
|
||||
} else {
|
||||
nReply.ErrCode = errCode
|
||||
nReply.ErrMsg = errMsg
|
||||
ws.sendMsgResp(conn, m, nReply, sendTime)
|
||||
ws.sendMsgResp(conn, m, nReply)
|
||||
}
|
||||
|
||||
}
|
||||
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp, sendTime int64) {
|
||||
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
|
||||
// := make(map[string]interface{})
|
||||
|
||||
var mReplyData sdk_ws.UserSendMsgResp
|
||||
mReplyData.ClientMsgID = pb.GetClientMsgID()
|
||||
mReplyData.ServerMsgID = pb.GetServerMsgID()
|
||||
mReplyData.SendTime = sendTime
|
||||
mReplyData.SendTime = pb.GetSendTime()
|
||||
b, _ := proto.Marshal(&mReplyData)
|
||||
mReply := Resp{
|
||||
ReqIdentifier: m.ReqIdentifier,
|
||||
|
@ -46,7 +46,7 @@ type MsgCallBackResp struct {
|
||||
func (rpc *rpcChat) encapsulateMsgData(msg *sdk_ws.MsgData) {
|
||||
msg.ServerMsgID = GetMsgID(msg.SendID)
|
||||
if msg.SendTime == 0 {
|
||||
msg.SendTime = utils.GetCurrentTimestampByNano()
|
||||
msg.SendTime = utils.GetCurrentTimestampByMill()
|
||||
}
|
||||
switch msg.ContentType {
|
||||
case constant.Text:
|
||||
@ -252,7 +252,7 @@ func Notification(n *NotificationMsg, onlineUserOnly bool) {
|
||||
msg.MsgFrom = n.MsgFrom
|
||||
msg.ContentType = n.ContentType
|
||||
msg.SessionType = n.SessionType
|
||||
msg.CreateTime = utils.GetCurrentTimestampByNano()
|
||||
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
||||
msg.ClientMsgID = utils.GetMsgID(n.SendID)
|
||||
switch n.SessionType {
|
||||
case constant.GroupChatType:
|
||||
|
@ -187,12 +187,12 @@ message MsgData {
|
||||
int32 msgFrom = 10;
|
||||
int32 contentType = 11;
|
||||
bytes content = 12;
|
||||
repeated string forceList = 13;
|
||||
int64 seq = 14;
|
||||
int64 sendTime = 15;
|
||||
int64 createTime = 16;
|
||||
map<string, bool> options = 17;
|
||||
OfflinePushInfo offlinePushInfo = 18;
|
||||
int32 status = 17;
|
||||
map<string, bool> options = 18;
|
||||
OfflinePushInfo offlinePushInfo = 19;
|
||||
}
|
||||
|
||||
message OfflinePushInfo{
|
||||
|
Loading…
x
Reference in New Issue
Block a user