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

Create background task / service to prune online players if not seen in a threshold time #31

Closed
Maelstromeous opened this issue Jul 5, 2020 · 3 comments · Fixed by #105
Labels
enhancement New feature or request p2 Disruptive issues but not show stoppers

Comments

@Maelstromeous
Copy link
Member

Need a background task to prune the online players for the PS2 worlds. We also need to update handlers to keep this information fresh as possible, using a "last seen" unix timestamp. The task will run through the online players and check their last online times, and if it's over a certain threshhold (currently thinking 10 mins) remove them from being online.

Originally posted by @Maelstromeous in #23

@Maelstromeous Maelstromeous added the p2 Disruptive issues but not show stoppers label Jul 5, 2020
@Maelstromeous Maelstromeous added this to the Websocket revival milestone Jul 5, 2020
@microwavekonijn
Copy link
Member

https://github.com/ps2alerts/websocket/pull/23/files/8f267be18568e940d235e2a2b31728cd0c1ebf2a#r449925169

I don't think it needs to be its own service. However I would put a list like that into it's own class something like DecayingSet and use that. With some clever use of a WeakSet and a rotating array of normal Sets you can create better performance without having to iterate over all elements.

In general use Set and Map over Array and Object in these kind of cases. They have better performance as I believe it implements a heap under the hood(though don't quote me on that). Also WeakSet and WeakMap are pretty cool as they do not block the garbage collector from freeing memory.

@marci4
Copy link
Contributor

marci4 commented Jul 9, 2020

PlayerHandler contains a method to update the lastseen of a player.

@Maelstromeous
Copy link
Member Author

Thinking of iterating a map of players and check their last seen values, if it's higher than threshold, delete that entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p2 Disruptive issues but not show stoppers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants