-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Websock API cleanup #1782
Merged
Merged
Websock API cleanup #1782
Conversation
This file contains 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
We don't have to keep track of this much data between rects, so restructure things to make it more simple. This allows the JPEG parsing code to be a pure function which only depends on the input.
We don't need any full slice functionality, so let's change this to better march rQpeek8() and rQshiftBytes().
That is the modern way to handle operations that cannot complete immediately.
Use proper accessor functions instead of poking around in internal buffers.
Callers should be using rQwait() to ensure sufficient data is present, and not poke around in the internal buffering.
Callers should be properly aware of how much data they need, as they need to call rQwait() first to ensure the data is present.
Let's not duplicate this stuff when we have convenience functions.
We don't know how long the caller will hang on to this data, so we need to be safe by default and assume it will kept indefinitely. That means we can't return a reference to the internal buffer, as that will get overwritten with future messages. We want to avoid unnecessary copying in performance critical code, though. So allow code to explicitly ask for a shared buffer, assuming they know the data needs to be consumed immediately.
This is what we almost always want, and this makes it consistent with rQshift8() and rQshift16().
We are expected to preserve these and use them in our requests back to the server. We can't do that if we don't actually decode them correctly.
We don't know the server layout yet, so we can't preserve the screen id or flags yet at this point. Move it until after we've parsed everything.
Send real messages and avoid poking around in internals, as we weren't testing things correctly that way.
It takes too much time and can make the tests fail.
Makes for more robust and realistic tests.
There is no encoding/decoding in modern WebSockets, so let's clean up some of the old crud that no longer serves a purpose.
It's more robust to do this just before we need the space, rather than assume when the queue will be read and adjust things right after.
Callers shouldn't be poking around directly in to the send queue, but should use accessor functions like for the read queue.
Callers shouldn't have to deal with the internal buffering limits of Websock, so implicitly flush the buffer if more room is needed.
samhed
reviewed
Jul 24, 2023
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.
Nice cleanup. Looks good!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
More clean-up as a result of playing around with async functions. Follow-up to #1780.