fix(combat): remove plugin-side lifetime — backend accumulates now
The plugin's _lifetimeState was always identical to _sessionState because both started fresh on every load/login and accumulated the same events. Lifetime needs persistence across sessions. Fix: plugin now only maintains _sessionState and sends lifetime=null. The backend computes deltas between consecutive session snapshots and accumulates them into a persisted lifetime in the combat_stats DB table. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b48af81a13
commit
0b1abf69f9
2 changed files with 7 additions and 9 deletions
|
|
@ -13,7 +13,7 @@ namespace MosswartMassacre
|
||||||
///
|
///
|
||||||
/// Maintains two CombatSessionState objects:
|
/// Maintains two CombatSessionState objects:
|
||||||
/// - _sessionState: cleared on login / manual reset
|
/// - _sessionState: cleared on login / manual reset
|
||||||
/// - _lifetimeState: accumulated across sessions, never cleared
|
/// - Lifetime: accumulated on the backend by merging session deltas
|
||||||
///
|
///
|
||||||
/// Every 10 seconds, sends a combat_stats snapshot to MosswartOverlord
|
/// Every 10 seconds, sends a combat_stats snapshot to MosswartOverlord
|
||||||
/// via WebSocket so the browser dashboard can display the same grid
|
/// via WebSocket so the browser dashboard can display the same grid
|
||||||
|
|
@ -25,7 +25,6 @@ namespace MosswartMassacre
|
||||||
|
|
||||||
private readonly IPluginLogger _logger;
|
private readonly IPluginLogger _logger;
|
||||||
private CombatSessionState _sessionState = new CombatSessionState();
|
private CombatSessionState _sessionState = new CombatSessionState();
|
||||||
private CombatSessionState _lifetimeState = new CombatSessionState();
|
|
||||||
private System.Windows.Forms.Timer _sendTimer;
|
private System.Windows.Forms.Timer _sendTimer;
|
||||||
private bool _dirty;
|
private bool _dirty;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
@ -34,7 +33,6 @@ namespace MosswartMassacre
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_sessionState.SessionStart = DateTime.UtcNow.ToString("o");
|
_sessionState.SessionStart = DateTime.UtcNow.ToString("o");
|
||||||
_lifetimeState.SessionStart = DateTime.UtcNow.ToString("o");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
|
|
@ -198,7 +196,7 @@ namespace MosswartMassacre
|
||||||
};
|
};
|
||||||
|
|
||||||
apply(_sessionState);
|
apply(_sessionState);
|
||||||
apply(_lifetimeState);
|
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,7 +217,7 @@ namespace MosswartMassacre
|
||||||
};
|
};
|
||||||
|
|
||||||
apply(_sessionState);
|
apply(_sessionState);
|
||||||
apply(_lifetimeState);
|
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,7 +233,7 @@ namespace MosswartMassacre
|
||||||
};
|
};
|
||||||
|
|
||||||
apply(_sessionState);
|
apply(_sessionState);
|
||||||
apply(_lifetimeState);
|
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,7 +249,7 @@ namespace MosswartMassacre
|
||||||
};
|
};
|
||||||
|
|
||||||
apply(_sessionState);
|
apply(_sessionState);
|
||||||
apply(_lifetimeState);
|
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,7 +265,7 @@ namespace MosswartMassacre
|
||||||
};
|
};
|
||||||
|
|
||||||
apply(_sessionState);
|
apply(_sessionState);
|
||||||
apply(_lifetimeState);
|
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -541,7 +539,7 @@ namespace MosswartMassacre
|
||||||
character_name = SafeCharacterName(),
|
character_name = SafeCharacterName(),
|
||||||
session_id = WebSocket.SessionId ?? "",
|
session_id = WebSocket.SessionId ?? "",
|
||||||
session = _sessionState,
|
session = _sessionState,
|
||||||
lifetime = _lifetimeState,
|
lifetime = (object)null, // lifetime is accumulated on the backend
|
||||||
};
|
};
|
||||||
_ = WebSocket.SendCombatStatsAsync(payload);
|
_ = WebSocket.SendCombatStatsAsync(payload);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue