-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Throttle download net message #86
Conversation
Thanks so much for this PR! I will review this and merge as soon as I get a chance - likely at the weekend. 😄 |
@brandonsturgeon I don't know if I'm missing something, but can you explain what happens when you join a server for the first time with this pull request? I'm concerned that the user will automatically run the network request textscreens_download from ENT:Initialize() for as many times as there are placed text screens - resulting in data not being sent if the client is capped to 1 request a second, where a different request is required for each entity. I would instead propose a cap on each individual text screen. I presume the player can only ever request this once per screen as GMod isn't going to try and retry the network requests, and the client only ever calls it when the entity is initialised on the client. So the cap could be once per text screen. Future updates are directly triggered by the server and sent to the client, so they wouldn't be affected by any caps. In terms of implementation, I'm thinking of using your existing idea of tying the data to the player entity so that it's cleaned up on disconnect, however, as it needs to keep track of each text screen entity that they have received an update for, you might want to add an EntityRemoved https://wiki.facepunch.com/gmod/GM:EntityRemoved hook to clean up removed text screens from the player's text screen update table. Hope this helps :) |
Hey @zakarybk - thanks for the reply. I'm booked up today, but I'll get some answers for you tomorrow. |
Let me know once you've had a chance to address Zak's comments @brandonsturgeon. Thanks again for the PR! |
Sorry, I'm injured and unable to do much right now. I'll circle back when I recover. Thanks |
Oh no worries at all - wishing you a speedy recovery! |
722be73
to
3467c8d
Compare
Sorry for the long delay. Life got away from me for awhile there :)
I tested this by spawning 10 screens on top of spawn and then rejoining. I added a print to
And here's what the tracking table looked like on my player ent:
Visually, everything seemed to work fine. All of the screens requested their data and displayed it correctly on the screen 👍
This is how it works currently. Each player has a table on them keeping track of the last time they requested the lines for a given screen entity (
Good point! I added a new |
Hi @brandonsturgeon, nice work. The logic looks sound. Thanks for attaching your tests. I haven't tested locally because I'm sure @Cherry will do that. |
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.
This looks great, thanks Brandon! Sorry for the delay in review on my part. This'll land on the Workshop very shortly.
This should address a relatively minor issue that would allow malicious players to spam-download a text screen's current state.
It simply throttles the download net message to once per second.
Because the throttles are stored on the player, the memory for the throttles should be self-managed as players leave.
I also reworked the net update itself:
Moving the networking into a function on the entity will let other addons control if/when screen updates occur.