From 79fee6bc06a04a2c01b81ec2470a67594bceaf6e Mon Sep 17 00:00:00 2001 From: wtz Date: Sun, 22 Feb 2026 23:04:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=8E=A9=E5=AE=B6=E9=87=8D=E8=BF=9E?= =?UTF-8?q?=E6=97=B6=E5=88=B7=E6=96=B0=E7=94=A8=E6=88=B7-=E6=88=BF?= =?UTF-8?q?=E9=97=B4=E5=85=B3=E8=81=94=E7=9A=84TTL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/internal/game/game.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/internal/game/game.go b/app/internal/game/game.go index 8b749c3..328cc1d 100644 --- a/app/internal/game/game.go +++ b/app/internal/game/game.go @@ -454,18 +454,20 @@ func (gm *GameManager) LeaveRoomWithTTL(roomID, playerID string) error { func (gm *GameManager) MarkPlayerOnline(roomID, playerID string) { gm.mu.Lock() defer gm.mu.Unlock() - ctx := context.Background() room, err := gm.loadRoom(ctx, roomID) if err != nil { return } - for _, p := range room.Players { if p.ID == playerID { p.IsOnline = true gm.saveRoom(ctx, room) gm.rdb.Delete(ctx, redis.PlayerTTLKey(playerID)) + // 刷新用户-房间关联的TTL + if p.UserID != "" { + gm.rdb.Set(ctx, redis.UserRoomKey(p.UserID), roomID, redis.RoomTTL) + } return } }