-
Notifications
You must be signed in to change notification settings - Fork 500
Allow registering large payloads with deferred max packet size #5119
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
Open
DennisOchulor
wants to merge
7
commits into
FabricMC:26.1
Choose a base branch
from
DennisOchulor:modify-large-payload-size
base: 26.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9c61a6f
port from 1.21.11
DennisOchulor 3d91125
change some names and improve impl
DennisOchulor 7292c90
refactor test
DennisOchulor cc753db
compare against padded size
DennisOchulor 0697cc7
tests: update max packet size on both sides separately
DennisOchulor 13ee5b3
throw if packet type is not registered for getMaxPacketSize()
DennisOchulor bfe0a7f
change to registerLarge overload
DennisOchulor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm just thinking of alternatives to this API, it does feel a little weird to have a setter that has to be called after registering with a possibly unknown inital max size.
I was wondering if taking a ToIntFunction (T being the payload) in a
registerLargeoverload would be a better API. I then realised that will only work for encoding 🤔.My only other ideas are taking an
IntFunctionor maven even aAtomicInteger, neither of which I love.(Im just thinking out loud so let me know what you think).
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.
Ya it does feel a bit weird, but personally I still prefer the setter. The other approaches would mean the max size could change arbitrarily, so the value would need to be revalidated each time. The max size could also be decreased from a previously set value which the current API doesn't allow (though I suppose we could just allow it? not sure if that would cause any problems).
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.
Again thinking out loud:
It does seem wrong to allow changing this during gameplay/after packets have been sent, could it take a function to return the max size once per connection/server instance?
E.g In the constructor of FabricPacketMerger/Splitter it could compute the max packet sizes for all registered types?
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.
Perhaps a
registerLargeoverload that takes anIntSupplierthat is called once right before the first packet of a payload type is sent/received? Should be sufficient for the data attachment API assuming no large attachments are registered after mod init.Uh oh!
There was an error while loading. Please reload this page.
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.
I've made the above change. I also removed
getMaxPacketSize()as I feel the new design doesn't really need it.