-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
Pull Request Test Coverage Report for Build 114
💛 - Coveralls |
Maybe we should make all currently used regions available as a utility function some where? |
There was a problem hiding this 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} |
There was a problem hiding this comment.
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.
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