mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
batch push
This commit is contained in:
parent
0babf89aa5
commit
9eb0dd5e70
39
internal/msg_gateway/gate/batch_push.go
Normal file
39
internal/msg_gateway/gate/batch_push.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package gate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
|
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var MaxPullMsgNum = 100
|
||||||
|
|
||||||
|
func (r *RPCServer) GenPullSeqList(currentSeq uint32, operationID string, userID string) ([]uint32, error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *RPCServer) GetSingleMsgForPush(operationID string, msgData *sdk_ws.MsgData, pushToUserID string, platformID string) []*sdk_ws.MsgData {
|
||||||
|
seqList, err := r.GenPullSeqList(msgData.Seq, operationID, pushToUserID)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
rpcReq := sdk_ws.PullMessageBySeqListReq{}
|
||||||
|
rpcReq.SeqList = seqList
|
||||||
|
rpcReq.UserID = pushToUserID
|
||||||
|
rpcReq.OperationID = operationID
|
||||||
|
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
|
msgClient := pbChat.NewChatClient(grpcConn)
|
||||||
|
reply, err := msgClient.PullMessageBySeqList(context.Background(), &rpcReq)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *RPCServer) GetBatchMsgForPush(operationID string, msgData *sdk_ws.MsgData, pushToUserIDList []string, platformID string) map[string][]*sdk_ws.MsgData {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *RPCServer) GetMaxSeq(userID string) (uint32, error) {
|
||||||
|
return 0, nil
|
||||||
|
}
|
@ -7,7 +7,6 @@ import (
|
|||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbRelay "Open_IM/pkg/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
@ -144,10 +143,6 @@ func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUser
|
|||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RPCServer) GetBatchMsgForPush(operationID string, msgData *sdk_ws.MsgData, pushToUserIDList []string, platformID string) map[string][]*sdk_ws.MsgData {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *RPCServer) OnlineBatchPushOneMsg(_ context.Context, req *pbRelay.OnlineBatchPushOneMsgReq) (*pbRelay.OnlineBatchPushOneMsgResp, error) {
|
func (r *RPCServer) OnlineBatchPushOneMsg(_ context.Context, req *pbRelay.OnlineBatchPushOneMsgReq) (*pbRelay.OnlineBatchPushOneMsgResp, error) {
|
||||||
log.NewInfo(req.OperationID, "BatchPushMsgToUser is arriving", req.String())
|
log.NewInfo(req.OperationID, "BatchPushMsgToUser is arriving", req.String())
|
||||||
var singleUserResult []*pbRelay.SingelMsgToUserResultList
|
var singleUserResult []*pbRelay.SingelMsgToUserResultList
|
||||||
|
@ -61,7 +61,7 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
//Connection mapping relationship,
|
//Connection mapping relationship,
|
||||||
//userID+" "+platformID->conn
|
//userID+" "+platformID->conn
|
||||||
//Initialize a lock for each user
|
//Initialize a lock for each user
|
||||||
newConn := &UserConn{conn, new(sync.Mutex)}
|
newConn := &UserConn{conn, new(sync.Mutex), 0}
|
||||||
userCount++
|
userCount++
|
||||||
ws.addUserConn(query["sendID"][0], utils.StringToInt(query["platformID"][0]), newConn, query["token"][0])
|
ws.addUserConn(query["sendID"][0], utils.StringToInt(query["platformID"][0]), newConn, query["token"][0])
|
||||||
go ws.readMsg(newConn)
|
go ws.readMsg(newConn)
|
||||||
|
@ -63,7 +63,7 @@ func (s *friendServer) Run() {
|
|||||||
defer srv.GracefulStop()
|
defer srv.GracefulStop()
|
||||||
//User friend related services register to etcd
|
//User friend related services register to etcd
|
||||||
pbFriend.RegisterFriendServer(srv, s)
|
pbFriend.RegisterFriendServer(srv, s)
|
||||||
rpcRegisterIP := ""
|
rpcRegisterIP := config.Config.RpcRegisterIP
|
||||||
if config.Config.RpcRegisterIP == "" {
|
if config.Config.RpcRegisterIP == "" {
|
||||||
rpcRegisterIP, err = utils.GetLocalIP()
|
rpcRegisterIP, err = utils.GetLocalIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user