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