Show live online-players count on the home screen
- OnlineService.getOnlineCount(); mock random-walks a believable number, SignalrService reads GET /api/stats/online (server tracks hub connections) - Home screen badge with pulsing dot, polls every 8s, localized digits Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -135,9 +135,18 @@ public sealed class GameManager
|
||||
public void ChooseTrump(string userId, string suit) => RoomOf(userId)?.HumanChooseTrump(userId, suit);
|
||||
public void SendReaction(string userId, string reaction) => RoomOf(userId)?.Reaction(userId, reaction);
|
||||
|
||||
public void OnConnected(string userId) => RoomOf(userId)?.SetConnected(userId, true);
|
||||
private int _online;
|
||||
public int OnlineCount => Volatile.Read(ref _online);
|
||||
|
||||
public void OnConnected(string userId)
|
||||
{
|
||||
Interlocked.Increment(ref _online);
|
||||
RoomOf(userId)?.SetConnected(userId, true);
|
||||
}
|
||||
|
||||
public void OnDisconnected(string userId)
|
||||
{
|
||||
if (Interlocked.Decrement(ref _online) < 0) Interlocked.Exchange(ref _online, 0);
|
||||
CancelMatchmaking(userId);
|
||||
RoomOf(userId)?.SetConnected(userId, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user