mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-06-03 22:39:28 +08:00
sendKickMsg add operationID
This commit is contained in:
parent
e813016402
commit
08ed131e19
@ -376,7 +376,7 @@ func (r *RPCServer) KickUserOffline(_ context.Context, req *pbRelay.KickUserOffl
|
|||||||
oldConnMap := ws.getUserAllCons(v)
|
oldConnMap := ws.getUserAllCons(v)
|
||||||
if conn, ok := oldConnMap[int(req.PlatformID)]; ok { // user->map[platform->conn]
|
if conn, ok := oldConnMap[int(req.PlatformID)]; ok { // user->map[platform->conn]
|
||||||
log.NewWarn(req.OperationID, "send kick msg, close connection ", req.PlatformID, v)
|
log.NewWarn(req.OperationID, "send kick msg, close connection ", req.PlatformID, v)
|
||||||
ws.sendKickMsg(conn)
|
ws.sendKickMsg(conn, req.OperationID)
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn
|
|||||||
if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn]
|
if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn]
|
||||||
if oldConn, ok := oldConnMap[platformID]; ok {
|
if oldConn, ok := oldConnMap[platformID]; ok {
|
||||||
log.NewDebug(operationID, uid, platformID, "kick old conn")
|
log.NewDebug(operationID, uid, platformID, "kick old conn")
|
||||||
ws.sendKickMsg(oldConn)
|
ws.sendKickMsg(oldConn, operationID)
|
||||||
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
|
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
|
||||||
if err != nil && err != go_redis.Nil {
|
if err != nil && err != go_redis.Nil {
|
||||||
log.NewError(operationID, "get token from redis err", err.Error(), uid, constant.PlatformIDToName(platformID))
|
log.NewError(operationID, "get token from redis err", err.Error(), uid, constant.PlatformIDToName(platformID))
|
||||||
@ -302,11 +302,12 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn
|
|||||||
case constant.WebAndOther:
|
case constant.WebAndOther:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (ws *WServer) sendKickMsg(oldConn *UserConn) {
|
func (ws *WServer) sendKickMsg(oldConn *UserConn, operationID string) {
|
||||||
mReply := Resp{
|
mReply := Resp{
|
||||||
ReqIdentifier: constant.WSKickOnlineMsg,
|
ReqIdentifier: constant.WSKickOnlineMsg,
|
||||||
ErrCode: constant.ErrTokenInvalid.ErrCode,
|
ErrCode: constant.ErrTokenInvalid.ErrCode,
|
||||||
ErrMsg: constant.ErrTokenInvalid.ErrMsg,
|
ErrMsg: constant.ErrTokenInvalid.ErrMsg,
|
||||||
|
OperationID: operationID,
|
||||||
}
|
}
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
enc := gob.NewEncoder(&b)
|
enc := gob.NewEncoder(&b)
|
||||||
@ -422,19 +423,19 @@ func (ws *WServer) getUserAllCons(uid string) map[int]*UserConn {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (ws *WServer) getUserUid(conn *UserConn) (uid string, platform int) {
|
// func (ws *WServer) getUserUid(conn *UserConn) (uid string, platform int) {
|
||||||
// rwLock.RLock()
|
// rwLock.RLock()
|
||||||
// defer rwLock.RUnlock()
|
// defer rwLock.RUnlock()
|
||||||
//
|
//
|
||||||
// if stringMap, ok := ws.wsConnToUser[conn]; ok {
|
// if stringMap, ok := ws.wsConnToUser[conn]; ok {
|
||||||
// for k, v := range stringMap {
|
// for k, v := range stringMap {
|
||||||
// platform = k
|
// platform = k
|
||||||
// uid = v
|
// uid = v
|
||||||
|
// }
|
||||||
|
// return uid, platform
|
||||||
// }
|
// }
|
||||||
// return uid, platform
|
// return "", 0
|
||||||
// }
|
// }
|
||||||
// return "", 0
|
|
||||||
//}
|
|
||||||
func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request, operationID string) (isPass, compression bool) {
|
func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request, operationID string) (isPass, compression bool) {
|
||||||
status := http.StatusUnauthorized
|
status := http.StatusUnauthorized
|
||||||
query := r.URL.Query()
|
query := r.URL.Query()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user