Skip to content

feat(proxy): expose network-wide player counts per backend server#15

Draft
hbrombeer wants to merge 1 commit into
mainfrom
feat/network-player-counts
Draft

feat(proxy): expose network-wide player counts per backend server#15
hbrombeer wants to merge 1 commit into
mainfrom
feat/network-player-counts

Conversation

@hbrombeer

Copy link
Copy Markdown
Member

Why

ProxyService is the seam every plugin uses to reason about players on other proxies — resolve a name, send a message, transfer them. The one thing it could not do was count them, so /agones fell back to Velocity's playersConnected, which is proxy-local by definition and reported "1 player" in a lobby holding two.

What

  • PlayerSessionQuery.countPlayersByServer() — implemented by plugin-player, backed by service-player's session table.
  • ProxyService.getNetworkPlayerCounts() — what consumers call.
  • NetworkPlayerCounts(byServer, total). A server nobody is on is absent rather than zero; total includes players not yet on a backend server, so it can exceed the sum.

Returns null, not a local fallback. Every other ProxyService method degrades to a local answer when no PlayerSessionQuery is registered, and that is right for them — a local player is a correct answer to "where is this player". It is wrong for a count: a proxy-local number looks exactly like a network number once rendered, and quietly showing it is the bug. Callers should say the figure is proxy-local instead.

Merge order

2 of 5. Depends on nothing; blocks the consumer.

  1. feat(player): count online players per backend server library-grpc-contracts#71 → release library-grpc-contracts-player 0.4.0
  2. this PR → release plugin-proxy-api (0.2.0)
  3. service-player — implement the RPC
  4. plugin-player — implement countPlayersByServer()
  5. plugin-agones/agones reads the network numbers

Verified

./gradlew build green. Published locally as gg.grounds:plugin-proxy-api:0.2.0 and compiled plugin-player and plugin-agones against it.

A proxy can only count the players connected to itself, so with two proxies in
front of one lobby each of them reports half of it. ProxyService now answers for
the whole network, via the registered PlayerSessionQuery.

Returns null when the network cannot be asked, rather than falling back to this
proxy's own numbers: a local count is indistinguishable from a network count once
it is rendered, and silently showing the wrong one is the bug being fixed.
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.

1 participant