errcode
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
@@ -34,8 +33,8 @@ func (r *RPCServer) GenPullSeqList(currentSeq uint32, operationID string, userID
|
||||
return seqList, nil
|
||||
}
|
||||
|
||||
func (r *RPCServer) GetSingleUserMsgForPushPlatforms(operationID string, msgData *sdk_ws.MsgData, pushToUserID string, platformIDList []int) map[int]*sdk_ws.MsgDataList {
|
||||
user2PushMsg := make(map[int]*sdk_ws.MsgDataList, 0)
|
||||
func (r *RPCServer) GetSingleUserMsgForPushPlatforms(operationID string, msgData *sdkws.MsgData, pushToUserID string, platformIDList []int) map[int]*sdkws.MsgDataList {
|
||||
user2PushMsg := make(map[int]*sdkws.MsgDataList, 0)
|
||||
for _, v := range platformIDList {
|
||||
user2PushMsg[v] = r.GetSingleUserMsgForPush(operationID, msgData, pushToUserID, v)
|
||||
//log.Info(operationID, "GetSingleUserMsgForPush", msgData.Seq, pushToUserID, v, "len:", len(user2PushMsg[v]))
|
||||
@@ -43,14 +42,14 @@ func (r *RPCServer) GetSingleUserMsgForPushPlatforms(operationID string, msgData
|
||||
return user2PushMsg
|
||||
}
|
||||
|
||||
func (r *RPCServer) GetSingleUserMsgForPush(operationID string, msgData *sdk_ws.MsgData, pushToUserID string, platformID int) *sdk_ws.MsgDataList {
|
||||
func (r *RPCServer) GetSingleUserMsgForPush(operationID string, msgData *sdkws.MsgData, pushToUserID string, platformID int) *sdkws.MsgDataList {
|
||||
//msgData.MsgDataList = nil
|
||||
return &sdk_ws.MsgDataList{MsgDataList: []*sdk_ws.MsgData{msgData}}
|
||||
return &sdkws.MsgDataList{MsgDataList: []*sdkws.MsgData{msgData}}
|
||||
|
||||
//userConn := ws.getUserConn(pushToUserID, platformID)
|
||||
//if userConn == nil {
|
||||
// log.Debug(operationID, "userConn == nil")
|
||||
// return []*sdk_ws.MsgData{msgData}
|
||||
// return []*sdkws.MsgData{msgData}
|
||||
//}
|
||||
//
|
||||
//if msgData.Seq <= userConn.PushedMaxSeq {
|
||||
@@ -62,7 +61,7 @@ func (r *RPCServer) GetSingleUserMsgForPush(operationID string, msgData *sdk_ws.
|
||||
//if msgList == nil {
|
||||
// log.Debug(operationID, "GetSingleUserMsg msgList == nil", msgData.Seq, userConn.PushedMaxSeq)
|
||||
// userConn.PushedMaxSeq = msgData.Seq
|
||||
// return []*sdk_ws.MsgData{msgData}
|
||||
// return []*sdkws.MsgData{msgData}
|
||||
//}
|
||||
//msgList = append(msgList, msgData)
|
||||
//
|
||||
@@ -75,7 +74,7 @@ func (r *RPCServer) GetSingleUserMsgForPush(operationID string, msgData *sdk_ws.
|
||||
//return msgList
|
||||
}
|
||||
|
||||
func (r *RPCServer) GetSingleUserMsg(operationID string, currentMsgSeq uint32, userID string) []*sdk_ws.MsgData {
|
||||
func (r *RPCServer) GetSingleUserMsg(operationID string, currentMsgSeq uint32, userID string) []*sdkws.MsgData {
|
||||
seqList, err := r.GenPullSeqList(currentMsgSeq, operationID, userID)
|
||||
if err != nil {
|
||||
log.Error(operationID, "GenPullSeqList failed ", err.Error(), currentMsgSeq, userID)
|
||||
@@ -85,7 +84,7 @@ func (r *RPCServer) GetSingleUserMsg(operationID string, currentMsgSeq uint32, u
|
||||
log.Error(operationID, "GenPullSeqList len == 0 ", currentMsgSeq, userID)
|
||||
return nil
|
||||
}
|
||||
rpcReq := sdk_ws.PullMessageBySeqListReq{}
|
||||
rpcReq := sdkws.PullMessageBySeqListReq{}
|
||||
rpcReq.SeqList = seqList
|
||||
rpcReq.UserID = userID
|
||||
rpcReq.OperationID = operationID
|
||||
@@ -108,8 +107,8 @@ func (r *RPCServer) GetSingleUserMsg(operationID string, currentMsgSeq uint32, u
|
||||
return reply.List
|
||||
}
|
||||
|
||||
//func (r *RPCServer) GetBatchUserMsgForPush(operationID string, msgData *sdk_ws.MsgData, pushToUserIDList []string, platformID int) map[string][]*sdk_ws.MsgData {
|
||||
// user2PushMsg := make(map[string][]*sdk_ws.MsgData, 0)
|
||||
//func (r *RPCServer) GetBatchUserMsgForPush(operationID string, msgData *sdkws.MsgData, pushToUserIDList []string, platformID int) map[string][]*sdkws.MsgData {
|
||||
// user2PushMsg := make(map[string][]*sdkws.MsgData, 0)
|
||||
// for _, v := range pushToUserIDList {
|
||||
// user2PushMsg[v] = r.GetSingleUserMsgForPush(operationID, msgData, v, platformID)
|
||||
// }
|
||||
@@ -1,4 +1,4 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
cbApi "Open_IM/pkg/callback_struct"
|
||||
@@ -1,22 +0,0 @@
|
||||
package open_im_media
|
||||
|
||||
const (
|
||||
// Address gRPC服务地址
|
||||
Address = "127.0.0.1:11300"
|
||||
)
|
||||
|
||||
type Media struct {
|
||||
}
|
||||
|
||||
func NewMedia() *Media {
|
||||
return &Media{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
}
|
||||
|
||||
func (m *Media) CreateRoom(roomName string) (error, error) {
|
||||
return nil, nil
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -1,4 +1,4 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -6,11 +6,10 @@ import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
push "Open_IM/pkg/proto/push"
|
||||
pbRtc "Open_IM/pkg/proto/rtc"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"context"
|
||||
@@ -78,15 +77,15 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
|
||||
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier)
|
||||
nReply := new(sdk_ws.GetMaxAndMinSeqResp)
|
||||
nReply := new(sdkws.GetMaxAndMinSeqResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSGetNewestSeq, m.OperationID)
|
||||
log.Info(m.OperationID, "argsValidate ", isPass, errCode, errMsg)
|
||||
if isPass {
|
||||
rpcReq := sdk_ws.GetMaxAndMinSeqReq{}
|
||||
rpcReq.GroupIDList = data.(sdk_ws.GetMaxAndMinSeqReq).GroupIDList
|
||||
rpcReq := sdkws.GetMaxAndMinSeqReq{}
|
||||
rpcReq.GroupIDList = data.(sdkws.GetMaxAndMinSeqReq).GroupIDList
|
||||
rpcReq.UserID = m.SendID
|
||||
rpcReq.OperationID = m.OperationID
|
||||
log.Debug(m.OperationID, "Ws call success to getMaxAndMinSeq", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdk_ws.GetMaxAndMinSeqReq).GroupIDList)
|
||||
log.Debug(m.OperationID, "Ws call success to getMaxAndMinSeq", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdkws.GetMaxAndMinSeqReq).GroupIDList)
|
||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, rpcReq.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := rpcReq.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
@@ -115,7 +114,7 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
}
|
||||
}
|
||||
|
||||
func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *sdk_ws.GetMaxAndMinSeqResp) {
|
||||
func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *sdkws.GetMaxAndMinSeqResp) {
|
||||
|
||||
b, _ := proto.Marshal(pb)
|
||||
mReply := Resp{
|
||||
@@ -133,15 +132,15 @@ func (ws *WServer) getSeqResp(conn *UserConn, m *Req, pb *sdk_ws.GetMaxAndMinSeq
|
||||
|
||||
func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq start", m.SendID, m.ReqIdentifier, m.MsgIncr, string(m.Data))
|
||||
nReply := new(sdk_ws.PullMessageBySeqListResp)
|
||||
nReply := new(sdkws.PullMessageBySeqListResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSPullMsgBySeqList, m.OperationID)
|
||||
if isPass {
|
||||
rpcReq := sdk_ws.PullMessageBySeqListReq{}
|
||||
rpcReq.SeqList = data.(sdk_ws.PullMessageBySeqListReq).SeqList
|
||||
rpcReq := sdkws.PullMessageBySeqListReq{}
|
||||
rpcReq.SeqList = data.(sdkws.PullMessageBySeqListReq).SeqList
|
||||
rpcReq.UserID = m.SendID
|
||||
rpcReq.OperationID = m.OperationID
|
||||
rpcReq.GroupSeqList = data.(sdk_ws.PullMessageBySeqListReq).GroupSeqList
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdk_ws.PullMessageBySeqListReq).SeqList)
|
||||
rpcReq.GroupSeqList = data.(sdkws.PullMessageBySeqListReq).GroupSeqList
|
||||
log.NewInfo(m.OperationID, "Ws call success to pullMsgBySeqListReq middle", m.SendID, m.ReqIdentifier, m.MsgIncr, data.(sdkws.PullMessageBySeqListReq).SeqList)
|
||||
grpcConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, m.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := rpcReq.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
@@ -169,7 +168,7 @@ func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||
ws.pullMsgBySeqListResp(conn, m, nReply)
|
||||
}
|
||||
}
|
||||
func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullMessageBySeqListResp) {
|
||||
func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdkws.PullMessageBySeqListResp) {
|
||||
log.NewInfo(m.OperationID, "pullMsgBySeqListResp come here ", pb.String())
|
||||
c, _ := proto.Marshal(pb)
|
||||
mReply := Resp{
|
||||
@@ -229,7 +228,7 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
||||
nReply := new(pbChat.SendMsgResp)
|
||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg, m.OperationID)
|
||||
if isPass {
|
||||
data := pData.(sdk_ws.MsgData)
|
||||
data := pData.(sdkws.MsgData)
|
||||
pbData := pbChat.SendMsgReq{
|
||||
Token: m.Token,
|
||||
OperationID: m.OperationID,
|
||||
@@ -265,7 +264,7 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
||||
|
||||
}
|
||||
func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
|
||||
var mReplyData sdk_ws.UserSendMsgResp
|
||||
var mReplyData sdkws.UserSendMsgResp
|
||||
mReplyData.ClientMsgID = pb.GetClientMsgID()
|
||||
mReplyData.ServerMsgID = pb.GetServerMsgID()
|
||||
mReplyData.SendTime = pb.GetSendTime()
|
||||
@@ -307,7 +306,7 @@ func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
||||
return
|
||||
}
|
||||
signalResp.Payload = respPb.SignalResp.Payload
|
||||
msgData := sdk_ws.MsgData{}
|
||||
msgData := sdkws.MsgData{}
|
||||
utils.CopyStructFields(&msgData, respPb.MsgData)
|
||||
log.NewInfo(m.OperationID, utils.GetSelfFuncName(), respPb.String())
|
||||
if respPb.IsPass {
|
||||
@@ -406,7 +405,7 @@ func SetTokenKicked(userID string, platformID int, operationID string) {
|
||||
func (ws *WServer) setUserDeviceBackground(conn *UserConn, m *Req) {
|
||||
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WsSetBackgroundStatus, m.OperationID)
|
||||
if isPass {
|
||||
req := pData.(*sdk_ws.SetAppBackgroundStatusReq)
|
||||
req := pData.(*sdkws.SetAppBackgroundStatusReq)
|
||||
conn.IsBackground = req.IsBackground
|
||||
callbackResp := callbackUserOnline(m.OperationID, conn.userID, int(conn.PlatformID), conn.token, conn.IsBackground, conn.connID)
|
||||
if callbackResp.ErrCode != 0 {
|
||||
+3
-4
@@ -1,4 +1,4 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -6,9 +6,8 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"context"
|
||||
@@ -297,7 +296,7 @@ func (r *RPCServer) OnlineBatchPushOneMsg(_ context.Context, req *pbRelay.Online
|
||||
SinglePushResult: singleUserResult,
|
||||
}, nil
|
||||
}
|
||||
func (r *RPCServer) encodeWsData(wsData *sdk_ws.MsgData, operationID string) (bytes.Buffer, error) {
|
||||
func (r *RPCServer) encodeWsData(wsData *sdkws.MsgData, operationID string) (bytes.Buffer, error) {
|
||||
log.Debug(operationID, "encodeWsData begin", wsData.String())
|
||||
msgBytes, err := proto.Marshal(wsData)
|
||||
if err != nil {
|
||||
@@ -4,13 +4,13 @@
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/5/21 15:29).
|
||||
*/
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbRtc "Open_IM/pkg/proto/rtc"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdkws"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package gate
|
||||
package msggateway
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/common/tokenverify"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
Reference in New Issue
Block a user