-
Notifications
You must be signed in to change notification settings - Fork 29
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
RoRnet UDP networking via ENet #143
Draft
ohlidalp
wants to merge
9
commits into
RigsOfRods:master
Choose a base branch
from
ohlidalp:enet
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.
Draft
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
Dumped full .tar.gz download of enet to /dependencies/enet/. Tested to build and link.
For maximum backwards compatibility, RoRnet version was bumped, SocketW is kept and server still listens for TCP connections on ip/port advertised on master server. Integration with master server is unchanged. Client version check is also unchanged. Only if client version matches, the server instructs the client to reconnect using ENet (using pre-existing unused RoRnet message MSG2_VERSION). ENet communication is exactly the same as legacy TCP connection, with only one cosmetic detail - server info is sent to client using pre-existing unused RoRnet message MSG2_SERVER_SETTINGS rather than MSG2_HELLO. Server listens for ENet connections on the same IP as TCP and port+1. This is a prototype done with minimum code changes, for easy understanding. Breakdown: * listener.cpp (class Listner) - removed all TCP connection handling except version check and master server info query. Compatible clients are instructed to reconnect via ENet. * dispatcher_enet.h/cpp (class DispatcherENet) - took over all connection handling logic from legacy Listener, except master server integration. Client version is checked again. * sequencer.h/cpp (class User) - removed TCP socket and send/recv threads (classes Broadcaster, Receiver), deleted "FLOW mode" system ('m_is_receiving_data' flag and `SetReceiveData()` func - related to recv thrad). Added ENetPeer and DispatcherENet. Created function `MessageReceived()` which processes all incoming packets for this user, including intial HELLO. * receiver.h/cpp (class Receiver) - deleted tcp recv thread, replaced by ENet. * broadcaster.h/cpp (class Broadcaster) - deleted tcp send thread, replaced by ENet. * sequencer.h/cpp (class Sequencer) - deleted killer thread and crash statistics, useless with ENet. Deleted "FLOW mode" system (function `enableFlow()` - related to send/recv threads). Function `createClient()` changed to `registerClient()` because the client object is now created early inside DispatcherENet. * rorserver.cpp - use new DispatcherEnet, keep existing Listener
This was referenced Apr 29, 2022
Closed
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.
Until now RoRnet protocol worked on top of raw TCP. This worked decently but limited the number of players/vehicles. For a good read on why TCP doesn't make good game networking, see https://gafferongames.com/post/udp_vs_tcp/.
This branch replaces raw TCP with ENet protocol (http://enet.bespin.org/) which works over UDP and provides reliable in-order delivery, so RoRnet can work with it out-of-the-box. At the moment, all communication uses the reliable mode, but in the future we'll make use of the unreliable, too.
To be done: