mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 18:45:58 +08:00
add batch push
This commit is contained in:
@@ -144,53 +144,53 @@ func (r *RPCServer) GetUsersOnlineStatus(_ context.Context, req *pbRelay.GetUser
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
//func (r *RPCServer) OnlineBatchPushOneMsg(_ context.Context, req *pbRelay.OnlineBatchPushOneMsgReq) (*pbRelay.OnlineBatchPushOneMsgResp, error) {
|
||||
// log.NewInfo(req.OperationID, "BatchPushMsgToUser is arriving", req.String())
|
||||
// var singleUserResult []*pbRelay.SingelMsgToUserResultList
|
||||
// //r.GetBatchMsgForPush(req.OperationID,req.MsgData,req.PushToUserIDList,)
|
||||
// msgBytes, _ := proto.Marshal(req.MsgData)
|
||||
// mReply := Resp{
|
||||
// ReqIdentifier: constant.WSPushMsg,
|
||||
// OperationID: req.OperationID,
|
||||
// Data: msgBytes,
|
||||
// }
|
||||
// var replyBytes bytes.Buffer
|
||||
// enc := gob.NewEncoder(&replyBytes)
|
||||
// err := enc.Encode(mReply)
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, "data encode err", err.Error())
|
||||
// }
|
||||
// for _, v := range req.PushToUserIDList {
|
||||
// var resp []*pbRelay.SingleMsgToUserPlatform
|
||||
// tempT := &pbRelay.SingelMsgToUserResultList{
|
||||
// UserID: v,
|
||||
// }
|
||||
// userConnMap := ws.getUserAllCons(v)
|
||||
// for platform, userConn := range userConnMap {
|
||||
// if userConn != nil {
|
||||
// resultCode := sendMsgBatchToUser(userConn, replyBytes.Bytes(), req, platform, v)
|
||||
// if resultCode == 0 && utils.IsContainInt(platform, r.pushTerminal) {
|
||||
// tempT.OnlinePush = true
|
||||
// log.Info(req.OperationID, "PushSuperMsgToUser is success By Ws", "args", req.String(), "recvPlatForm", constant.PlatformIDToName(platform), "recvID", v)
|
||||
// temp := &pbRelay.SingleMsgToUserPlatform{
|
||||
// ResultCode: resultCode,
|
||||
// RecvID: v,
|
||||
// RecvPlatFormID: int32(platform),
|
||||
// }
|
||||
// resp = append(resp, temp)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// tempT.Resp = resp
|
||||
// singleUserResult = append(singleUserResult, tempT)
|
||||
//
|
||||
// }
|
||||
//
|
||||
// return &pbRelay.OnlineBatchPushOneMsgResp{
|
||||
// SinglePushResult: singleUserResult,
|
||||
// }, nil
|
||||
//}
|
||||
func (r *RPCServer) SuperGroupOnlineBatchPushOneMsg(_ context.Context, req *pbRelay.OnlineBatchPushOneMsgReq) (*pbRelay.OnlineBatchPushOneMsgResp, error) {
|
||||
log.NewInfo(req.OperationID, "BatchPushMsgToUser is arriving", req.String())
|
||||
var singleUserResult []*pbRelay.SingelMsgToUserResultList
|
||||
//r.GetBatchMsgForPush(req.OperationID,req.MsgData,req.PushToUserIDList,)
|
||||
msgBytes, _ := proto.Marshal(req.MsgData)
|
||||
mReply := Resp{
|
||||
ReqIdentifier: constant.WSPushMsg,
|
||||
OperationID: req.OperationID,
|
||||
Data: msgBytes,
|
||||
}
|
||||
var replyBytes bytes.Buffer
|
||||
enc := gob.NewEncoder(&replyBytes)
|
||||
err := enc.Encode(mReply)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "data encode err", err.Error())
|
||||
}
|
||||
for _, v := range req.PushToUserIDList {
|
||||
var resp []*pbRelay.SingleMsgToUserPlatform
|
||||
tempT := &pbRelay.SingelMsgToUserResultList{
|
||||
UserID: v,
|
||||
}
|
||||
userConnMap := ws.getUserAllCons(v)
|
||||
for platform, userConn := range userConnMap {
|
||||
if userConn != nil {
|
||||
resultCode := sendMsgBatchToUser(userConn, replyBytes.Bytes(), req, platform, v)
|
||||
if resultCode == 0 && utils.IsContainInt(platform, r.pushTerminal) {
|
||||
tempT.OnlinePush = true
|
||||
log.Info(req.OperationID, "PushSuperMsgToUser is success By Ws", "args", req.String(), "recvPlatForm", constant.PlatformIDToName(platform), "recvID", v)
|
||||
temp := &pbRelay.SingleMsgToUserPlatform{
|
||||
ResultCode: resultCode,
|
||||
RecvID: v,
|
||||
RecvPlatFormID: int32(platform),
|
||||
}
|
||||
resp = append(resp, temp)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
tempT.Resp = resp
|
||||
singleUserResult = append(singleUserResult, tempT)
|
||||
|
||||
}
|
||||
|
||||
return &pbRelay.OnlineBatchPushOneMsgResp{
|
||||
SinglePushResult: singleUserResult,
|
||||
}, nil
|
||||
}
|
||||
func (r *RPCServer) OnlineBatchPushOneMsg(_ context.Context, req *pbRelay.OnlineBatchPushOneMsgReq) (*pbRelay.OnlineBatchPushOneMsgResp, error) {
|
||||
log.NewInfo(req.OperationID, "BatchPushMsgToUser is arriving", req.String())
|
||||
var singleUserResult []*pbRelay.SingelMsgToUserResultList
|
||||
|
||||
Reference in New Issue
Block a user