mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
alter rtc timeout
This commit is contained in:
parent
8a0c112072
commit
f4cdbe985e
@ -2,6 +2,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
log2 "Open_IM/pkg/common/log"
|
log2 "Open_IM/pkg/common/log"
|
||||||
pbChat "Open_IM/pkg/proto/chat"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
pbRtc "Open_IM/pkg/proto/rtc"
|
pbRtc "Open_IM/pkg/proto/rtc"
|
||||||
@ -203,3 +204,24 @@ func (d *DataBases) DelUserSignalList(userID string) error {
|
|||||||
err := d.rdb.Del(context.Background(), keyList).Err()
|
err := d.rdb.Del(context.Background(), keyList).Err()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) DelMsgFromCache(uid string, seqList []uint32, operationID string) {
|
||||||
|
for _, seq := range seqList {
|
||||||
|
key := messageCache + uid + "_" + strconv.Itoa(int(seq))
|
||||||
|
result := d.rdb.Get(context.Background(), key).String()
|
||||||
|
var msg pbCommon.MsgData
|
||||||
|
if err := utils.String2Pb(result, &msg); err != nil {
|
||||||
|
log2.Error(operationID, utils.GetSelfFuncName(), "String2Pb failed", msg, err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
msg.Status = constant.MsgDeleted
|
||||||
|
s, err := utils.Pb2String(&msg)
|
||||||
|
if err != nil {
|
||||||
|
log2.Error(operationID, utils.GetSelfFuncName(), "Pb2String failed", msg, err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := d.rdb.Set(context.Background(), key, s, time.Duration(config.Config.MsgCacheTimeout)*time.Second).Err(); err != nil {
|
||||||
|
log2.Error(operationID, utils.GetSelfFuncName(), "Set failed", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
log2 "Open_IM/pkg/common/log"
|
log2 "Open_IM/pkg/common/log"
|
||||||
pbChat "Open_IM/pkg/proto/chat"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
pbRtc "Open_IM/pkg/proto/rtc"
|
|
||||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -14,8 +13,6 @@ import (
|
|||||||
|
|
||||||
"github.com/garyburd/redigo/redis"
|
"github.com/garyburd/redigo/redis"
|
||||||
"github.com/golang/protobuf/jsonpb"
|
"github.com/golang/protobuf/jsonpb"
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
|
|
||||||
//osconfig "google.golang.org/genproto/googleapis/cloud/osconfig/v1alpha"
|
//osconfig "google.golang.org/genproto/googleapis/cloud/osconfig/v1alpha"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
@ -322,53 +319,53 @@ func (d *DataBases) SetMessageToCache(msgList []*pbChat.MsgDataToMQ, uid string,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) DelMsgFromCache(uid string, seqList []uint32, operationID string) {
|
//func (d *DataBases) DelMsgFromCache(uid string, seqList []uint32, operationID string) {
|
||||||
for _, seq := range seqList {
|
// for _, seq := range seqList {
|
||||||
key := messageCache + uid + "_" + strconv.Itoa(int(seq))
|
// key := messageCache + uid + "_" + strconv.Itoa(int(seq))
|
||||||
result, err := redis.String(d.Exec("GET", key))
|
// result, err := redis.String(d.Exec("GET", key))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log2.NewWarn(operationID, utils.GetSelfFuncName(), "redis failed", "args:", key)
|
// log2.NewWarn(operationID, utils.GetSelfFuncName(), "redis failed", "args:", key)
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
log2.Debug(operationID, utils.GetSelfFuncName(), "del result", result)
|
// log2.Debug(operationID, utils.GetSelfFuncName(), "del result", result)
|
||||||
var msg pbCommon.MsgData
|
// var msg pbCommon.MsgData
|
||||||
err = utils.String2Pb(result, &msg)
|
// err = utils.String2Pb(result, &msg)
|
||||||
log2.NewDebug(operationID, utils.GetSelfFuncName(), "msg", msg)
|
// log2.NewDebug(operationID, utils.GetSelfFuncName(), "msg", msg)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log2.NewWarn(operationID, utils.GetSelfFuncName(), "string2Pb failed", msg, err.Error())
|
// log2.NewWarn(operationID, utils.GetSelfFuncName(), "string2Pb failed", msg, err.Error())
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
msg.Status = constant.MsgDeleted
|
// msg.Status = constant.MsgDeleted
|
||||||
s, err := utils.Pb2String(&msg)
|
// s, err := utils.Pb2String(&msg)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log2.NewWarn(operationID, utils.GetSelfFuncName(), "Pb2String failed", msg, err.Error())
|
// log2.NewWarn(operationID, utils.GetSelfFuncName(), "Pb2String failed", msg, err.Error())
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
_, err = d.Exec("SET", key, s)
|
// _, err = d.Exec("SET", key, s)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log2.NewWarn(operationID, utils.GetSelfFuncName(), "redis failed", "args:", key, msg, s)
|
// log2.NewWarn(operationID, utils.GetSelfFuncName(), "redis failed", "args:", key, msg, s)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (d *DataBases) CacheSignalInfo(msg *pbCommon.MsgData) error {
|
//func (d *DataBases) CacheSignalInfo(msg *pbCommon.MsgData) error {
|
||||||
key := SignalCache + msg.ClientMsgID
|
// key := SignalCache + msg.ClientMsgID
|
||||||
_, err := d.Exec("SET", key, msg.Content, "ex", config.Config.Rtc.SignalTimeout)
|
// _, err := d.Exec("SET", key, msg.Content, "ex", config.Config.Rtc.SignalTimeout)
|
||||||
return err
|
// return err
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func (d *DataBases) GetSignalInfoFromCache(clientMsgID string) (invitationInfo *pbRtc.SignalInviteReq, err error) {
|
//func (d *DataBases) GetSignalInfoFromCache(clientMsgID string) (invitationInfo *pbRtc.SignalInviteReq, err error) {
|
||||||
key := SignalCache + clientMsgID
|
// key := SignalCache + clientMsgID
|
||||||
result, err := redis.Bytes(d.Exec("GET", key))
|
// result, err := redis.Bytes(d.Exec("GET", key))
|
||||||
log2.NewDebug("", utils.GetSelfFuncName(), clientMsgID, result, string(result))
|
// log2.NewDebug("", utils.GetSelfFuncName(), clientMsgID, result, string(result))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
req := &pbRtc.SignalReq{}
|
// req := &pbRtc.SignalReq{}
|
||||||
if err = proto.Unmarshal(result, req); err != nil {
|
// if err = proto.Unmarshal(result, req); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
req2 := req.Payload.(*pbRtc.SignalReq_Invite)
|
// req2 := req.Payload.(*pbRtc.SignalReq_Invite)
|
||||||
invitationInfo = req2.Invite
|
// invitationInfo = req2.Invite
|
||||||
return invitationInfo, err
|
// return invitationInfo, err
|
||||||
}
|
//}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user