Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add players_online api #102

Merged
merged 3 commits into from
Apr 13, 2018
Merged

Add players_online api #102

merged 3 commits into from
Apr 13, 2018

Conversation

Hanspagh
Copy link
Collaborator

@Hanspagh Hanspagh commented Apr 11, 2018

I decided to try to implement this in the player servers instead of the LeaveTracker, since it felt more like natural to have server manage the amount of players on them and this map directly to the amount of connected players, as long as a player can only join one server at a time.
This closes #76

@Hanspagh Hanspagh requested a review from ecly April 11, 2018 22:12
@coveralls
Copy link

coveralls commented Apr 11, 2018

Pull Request Test Coverage Report for Build 114

  • 12 of 12 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.4%) to 67.681%

Totals Coverage Status
Change from base Build 89: 1.4%
Covered Lines: 178
Relevant Lines: 263

💛 - Coveralls

@Hanspagh
Copy link
Collaborator Author

Maybe we should make all currently used regions available as a utility function some where?

Copy link
Member

@ecly ecly left a comment

Choose a reason for hiding this comment

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

Code looks really nice - and yeah, it does make sense to have it in the PlayerServer.

The only idea in having it in the LeaveTracker, was to reduce load on the PlayerServers. Depending on how we want to use it in the front-end, we could choose to additionally expose a count for individual regions in the api, such that if we just want to show count for the current region in the front-end, we wont have to retrieve results from all servers.

# Handle calls with count - synchronous
# Returns {:reply, <value returned to client>, <state>}
def handle_call({:count}, _from, list) do
{:reply, Enum.count(list), list}
Copy link
Member

Choose a reason for hiding this comment

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

My bad on the naming list in the PlayerServer. It should probably be changed to state everywhere. We should also use Kernel.map_size/1 here instead, as it runs in constant time.

@ecly ecly merged commit c70db5d into development Apr 13, 2018
@ecly ecly mentioned this pull request Apr 13, 2018
@ecly ecly deleted the add-stats-tracker branch April 16, 2018 17:32
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.

Add stats tracking
3 participants