Set token kicked status first in forceKickOff

pull/265/head
skiffer-git 2 years ago
parent 57a21ab8e6
commit 5cbea2cab5

@ -324,9 +324,9 @@ func SetGlobalRecvMessageOpt(c *gin.Context) {
func GetSelfUserInfo(c *gin.Context) {
params := api.GetSelfUserInfoReq{}
if err := c.BindJSON(&params); err != nil {
errMsg := "BindJSON failed " + err.Error()
log.NewError("0", "BindJSON failed ", errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
errMsg := " BindJSON failed " + err.Error()
log.NewError("0", errMsg)
c.JSON(http.StatusOK, gin.H{"errCode": 1001, "errMsg": errMsg})
return
}
req := &rpc.GetUserInfoReq{}
@ -338,8 +338,8 @@ func GetSelfUserInfo(c *gin.Context) {
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
log.NewError(params.OperationID, errMsg)
c.JSON(http.StatusOK, gin.H{"errCode": 1001, "errMsg": errMsg})
return
}

@ -291,14 +291,14 @@ func (r *RPCServer) encodeWsData(wsData *sdk_ws.MsgData, operationID string) (by
func (r *RPCServer) KickUserOffline(_ context.Context, req *pbRelay.KickUserOfflineReq) (*pbRelay.KickUserOfflineResp, error) {
log.NewInfo(req.OperationID, "KickUserOffline is arriving", req.String())
for _, v := range req.KickUserIDList {
log.NewWarn(req.OperationID, "SetTokenKicked ", v, req.PlatformID, req.OperationID)
SetTokenKicked(v, int(req.PlatformID), req.OperationID)
oldConnMap := ws.getUserAllCons(v)
if conn, ok := oldConnMap[int(req.PlatformID)]; ok { // user->map[platform->conn]
log.NewWarn(req.OperationID, "send kick msg, close connection ", req.PlatformID, v)
ws.sendKickMsg(conn, &UserConn{})
conn.Close()
}
log.NewWarn(req.OperationID, "SetTokenKicked ", v, req.PlatformID, req.OperationID)
SetTokenKicked(v, int(req.PlatformID), req.OperationID)
}
return &pbRelay.KickUserOfflineResp{}, nil
}

@ -67,11 +67,11 @@ func (rpc *rpcAuth) ForceLogout(_ context.Context, req *pbAuth.ForceLogoutReq) (
log.NewError(req.OperationID, errMsg)
return &pbAuth.ForceLogoutResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
}
if err := token_verify.DeleteToken(req.FromUserID, int(req.Platform)); err != nil {
errMsg := req.OperationID + " DeleteToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
log.NewError(req.OperationID, errMsg)
return &pbAuth.ForceLogoutResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
}
//if err := token_verify.DeleteToken(req.FromUserID, int(req.Platform)); err != nil {
// errMsg := req.OperationID + " DeleteToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
// log.NewError(req.OperationID, errMsg)
// return &pbAuth.ForceLogoutResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
//}
if err := rpc.forceKickOff(req.FromUserID, req.Platform, req.OperationID); err != nil {
errMsg := req.OperationID + " forceKickOff failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
log.NewError(req.OperationID, errMsg)

Loading…
Cancel
Save