-
-
Notifications
You must be signed in to change notification settings - Fork 67
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 Transport layer based on memory channels #117
Open
OleStrohm
wants to merge
9
commits into
lucaspoffo:master
Choose a base branch
from
OleStrohm:channel_transport
base: master
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.
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
UkoeHB
suggested changes
Oct 11, 2023
UkoeHB
approved these changes
Oct 11, 2023
I added a method to create a client with a specific client id in case people want to test reconnection strategies that rely on the client id. |
OleStrohm
force-pushed
the
channel_transport
branch
from
November 14, 2023 23:00
dc5dee1
to
d87075d
Compare
@OleStrohm I implemented memory channels as a netcode socket option in renet2. The channel part was re-implemented from scratch (not that many lines), but I did use your test suite from this PR. Here's the exact commit. |
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.
Overview
This pull request implements a transport layer based on the stdlib mpsc channel.
This allows the renet server and clients to communicate efficiently within a single program.
This is especially useful for testing networking code, where you want to be able to guarantee that messages arrive immediately, without having to go through the OS network layer.
This should also hopefully allow benchmarks to be more consistent.
It also allows more efficient emulation of a locally hosted server that actually runs within the same binary.
Notes
As this can only be used within the same program, I decided to only expose a way to create new clients from an already existing server. I think this method simplifies the API significantly, and doesn't diminish the ergonomics in the scenarios I am able of thinking of.
I'm not very happy with the current state of the
Connection
struct, so any advice on that would be very welcome. The problem arises from Sender/Receiver being!Sync
, but bevy resources need to beSync
. Bevy therefore provides aSyncCell
which can turnSend
types intoSync
types by only allowing access through a&mut SyncCell<T>
. However if this is used outside bevy, thenSyncCell
is not available. Thus in the current implementation the Transports are!Sync
when used standalone.The only good solution I can think of to remedy this would be to copy a barebones version of Bevy's SyncCell and use that. This isn't a great solution, but this struct isn't public outside of
renet_channel
, so it might be okay.I also wasn't sure what to do about the example, since this layer only runs within the same process you can't make a proper echo example, so I just added a whole bunch of tests.