Skip to content

Add game-wide player counts - #406

Merged
erikdubbelboer merged 3 commits into
mainfrom
getPlayerCounts
Oct 28, 2026
Merged

erikdubbelboer merged 3 commits into
mainfrom
getPlayerCounts

Conversation

@erikdubbelboer

Copy link
Copy Markdown
Member

Add network.getPlayerCounts() to return online and in-lobby session counts for the current game, including private lobbies.

Also mark peers disconnected when they explicitly close their network. Previously they remained marked connected until timeout, even though they had already left. This would keep the eligible for leader election.

Comment thread features/support/steps/network.ts Outdated
Comment thread internal/signaling/stores/postgres.go
Add network.getPlayerCounts() to return online and in-lobby session counts
for the current game, including private lobbies.

Also mark peers disconnected when they explicitly close their network.
Previously they remained marked connected until timeout, even though they
had already left. This would keep the eligible for leader election.
WHERE peers.peer = ANY(game_lobbies.peers) AND (`+where+`)
))
FROM peers
WHERE game = $1 AND disconnected = FALSE

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a pretty heavy query for a player count. Doesn't the WITH game_lobbies keep all lobbies in memory?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not MATERIALIZED so it will just be inlined instead of running that query first and then using the result for the outer query.

@erikdubbelboer
erikdubbelboer merged commit b0bbf50 into main Oct 28, 2026
8 checks passed
@erikdubbelboer
erikdubbelboer deleted the getPlayerCounts branch October 28, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants