fix: 玩家出牌/过牌时刷新UserRoomKey TTL
This commit is contained in:
@@ -646,6 +646,10 @@ func (gm *GameManager) PlayCards(roomID, playerID string, cards []models.Card) e
|
|||||||
}
|
}
|
||||||
|
|
||||||
gm.saveRoom(ctx, room)
|
gm.saveRoom(ctx, room)
|
||||||
|
// 刷新用户-房间关联的TTL
|
||||||
|
if player.UserID != "" {
|
||||||
|
gm.rdb.Set(ctx, redis.UserRoomKey(player.UserID), roomID, redis.RoomTTL)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,6 +690,13 @@ func (gm *GameManager) Pass(roomID, playerID string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gm.saveRoom(ctx, room)
|
gm.saveRoom(ctx, room)
|
||||||
|
// 刷新用户-房间关联的TTL
|
||||||
|
for _, p := range room.Players {
|
||||||
|
if p.ID == playerID && p.UserID != "" {
|
||||||
|
gm.rdb.Set(ctx, redis.UserRoomKey(p.UserID), roomID, redis.RoomTTL)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user