singal offline push

This commit is contained in:
wangchuxiao
2022-06-02 18:17:11 +08:00
parent f98da25fda
commit 16d33b1c1f
19 changed files with 718 additions and 224 deletions
+25
View File
@@ -5,6 +5,7 @@ import (
"Open_IM/pkg/common/constant"
log2 "Open_IM/pkg/common/log"
pbChat "Open_IM/pkg/proto/chat"
pbRtc "Open_IM/pkg/proto/rtc"
pbCommon "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"encoding/json"
@@ -12,6 +13,8 @@ import (
"fmt"
"github.com/garyburd/redigo/redis"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
osconfig "google.golang.org/genproto/googleapis/cloud/osconfig/v1alpha"
"strconv"
)
@@ -29,6 +32,7 @@ const (
blackListCache = "BLACK_LIST_CACHE:"
groupCache = "GROUP_CACHE:"
messageCache = "MESSAGE_CACHE:"
SignalCache = "Signal_CACHE:"
)
func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (interface{}, error) {
@@ -342,3 +346,24 @@ func (d *DataBases) DelMsgFromCache(uid string, seqList []uint32, operationID st
}
}
}
func (d *DataBases) CacheSignalInfo(msg *pbCommon.MsgData) error {
key := SignalCache + msg.ClientMsgID
_, err := d.Exec("SET", key, msg.Content, "ex", config.Config.Rtc.SignalTimeout)
return err
}
func (d *DataBases) GetSignalInfoFromCache(clientMsgID string) (invitationInfo *pbRtc.SignalInviteReq, err error) {
key := SignalCache + clientMsgID
result, err := redis.Bytes(d.Exec("GET", key))
log2.NewDebug("", utils.GetSelfFuncName(), clientMsgID, result)
if err != nil {
invitationInfo := &pbRtc.SignalInviteReq{}
return invitationInfo, err
}
req := &pbRtc.SignalMessageAssembleReq{}
err = proto.Unmarshal(result, req)
req2 := req.SignalReq.Payload.(*pbRtc.SignalReq_Invite)
invitationInfo = req2.Invite
return invitationInfo, err
}