mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-25 23:18:44 -07:00
fix: sub-room id sequence, restore sync, presence index TTL, permission races
From the local CodeRabbit review: - Scene ids: the repair and room clone assigned max + 1, which never advanced the Postgres identity sequence (live: sequence 3412, max id 3466), so the next add / clone sub-room would collide on the primary key. The repair now moves the sequence past the highest id at startup, and both let the database assign ids. - Room-level restores (datahistory/restore and the admin restore) now also restore the entry sub-room, whose blob room details serve first. - TouchRoom refreshes the room's presence index too, so players kept alive only by heartbeats no longer drop out of the instance browser after 20 min. - Sub-room permission saves match cells exactly (as the unique index does) and retry when a concurrent editor inserted the same new cell.
This commit is contained in:
@@ -141,7 +141,19 @@ public class PlayerPresenceService
|
||||
{
|
||||
try
|
||||
{
|
||||
mux.GetDatabase().KeyExpire(Key(playerId), PresenceTtl);
|
||||
var db = mux.GetDatabase();
|
||||
db.KeyExpire(Key(playerId), PresenceTtl);
|
||||
// Keep the room's membership index alive as long as its
|
||||
// members are: a player refreshed only through here would
|
||||
// otherwise outlive the set (SetRoom's 2 × TTL) and drop out
|
||||
// of the instance browser and room pushes.
|
||||
var json = db.StringGet(Key(playerId));
|
||||
if (json.HasValue &&
|
||||
JsonSerializer.Deserialize<RoomInstanceDto>(json.ToString(), JsonOpts) is { RoomId: > 0 } room)
|
||||
{
|
||||
db.SetAdd(RoomIndexKey(room.RoomId), playerId);
|
||||
db.KeyExpire(RoomIndexKey(room.RoomId), PresenceTtl + PresenceTtl);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user