-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
netplay: introduce abstractions for client/server-side sockets and connection providers #4105
Open
ManManson
wants to merge
3
commits into
Warzone2100:master
Choose a base branch
from
ManManson:higher_level_sockets
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
past-due
reviewed
Oct 25, 2024
ManManson
force-pushed
the
higher_level_sockets
branch
2 times, most recently
from
October 25, 2024 16:48
23c5fc0
to
d401946
Compare
ManManson
force-pushed
the
higher_level_sockets
branch
4 times, most recently
from
October 25, 2024 19:06
5353467
to
8cef02e
Compare
ManManson
force-pushed
the
higher_level_sockets
branch
3 times, most recently
from
November 16, 2024 12:16
7568a5c
to
6d1f975
Compare
Moved the async client connection code to the base |
ManManson
force-pushed
the
higher_level_sockets
branch
from
November 17, 2024 13:04
08721fb
to
770eb71
Compare
Changed |
…nnection providers This patch introduces multiple high-level abstractions over raw low-level sockets, which are necessary for supporting network backends other than default legacy `TCP_DIRECT` implementation: 1. `WzConnectionProvider` - abstracts the way WZ establishes server-side and client-side connections. This thing effectively provides usable listen sockets and client connections to work with, hence the name. 2. `IListenSocket` - abstraction over listen sockets. 3. `IClientConnection` - abstraction over client-side sockets (and also server-side connections to the game clients). 4. `IConnectionPollGroup` - generalization of socket sets for polling multiple connections in one go. 5. `ConnectionProviderRegistry` - trivial singleton class providing storage for connection providers. 6. `ConnectionAddress` - opaque connection address object, aimed to replace direct uses of `addrinfo` and provide a bit more abstract way to represent connection credentials. Still looks like a crutch right now, but it's better than nothing, nonetheless. The existing implementation in `netplay/netsocket.h(.cpp)` has been moved to the `tcp` subfolder and wrapped entirely into the `tcp` namespace. The patch provides `TCP*`-prefixed implementations of the base interfaces mentioned above, which are implemented in terms of the old `netsocket` code. There's now a `ConnectionProviderType::TCP_DIRECT` enumeration descriptor for accessing the default connection provider. All uses in the high-level code (`netplay.cpp`, `joiningscreen.cpp`) are amended appropriately to use the all-new high-level abstractions instead of old low-level tcp-specific `Socket` and `SocketSet`. NOTE: there are still a few functions from the `tcp::` namespace used directly in the Discord RPC integration code, but these shouldn't pose any problem to either extract these into a more generic abstraction layer or to be rewritten not to use these functions at all, because they don't actually use any low-level stuff that's hard to refactor. Signed-off-by: Pavel Solodovnikov <[email protected]>
This way it looks much cleaner and naturally doesn't leak any implementation details to clients. Also, now it's much easier to provide native connection address implementations for each backend implementation. Signed-off-by: Pavel Solodovnikov <[email protected]>
…e `WzConnectionProvider` Provide the default implementation for `openClientConnectionAsync()` in `WzConnectionProvider`, which just spawns a new thread and piggibacks on the `resolveHost()` + `openClientConnectionAny()` combination. The `TCPConnectionProvider` is now simpler because it can use the default implementation from the base class. Signed-off-by: Pavel Solodovnikov <[email protected]>
ManManson
force-pushed
the
higher_level_sockets
branch
from
November 17, 2024 13:13
770eb71
to
1ae4f40
Compare
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.
This patch introduces multiple high-level abstractions over raw low-level sockets, which are necessary for supporting network backends other than default legacy
TCP_DIRECT
implementation:WzConnectionProvider
- abstracts the way WZ establishes server-side and client-side connections. This thing effectively provides usable listen sockets and client connections to work with, hence the name.IListenSocket
- abstraction over listen sockets.IClientConnection
- abstraction over client-side sockets (and also server-side connections to the game clients).IConnectionPollGroup
- generalization of socket sets for polling multiple connections in one go.ConnectionProviderRegistry
- trivial singleton class providing storage for connection providers.IConnectionAddress
- opaque connection address object, aimed to replace direct uses ofaddrinfo
and provide a bit more abstract way to represent connection credentials.The existing implementation in
netplay/netsocket.h(.cpp)
has been moved to thetcp
subfolder and wrapped entirely into thetcp
namespace.The patch provides
TCP*
-prefixed implementations of the base interfaces mentioned above, which are implemented in terms of the oldnetsocket
code.There's now a
ConnectionProviderType::TCP_DIRECT
enumeration descriptor for accessing the default connection provider.All uses in the high-level code (
netplay.cpp
,joiningscreen.cpp
) are amended appropriately to use the all-new high-level abstractions instead of old low-level tcp-specificSocket
andSocketSet
.NOTE: there are still a few functions from the
tcp::
namespace used directly in the Discord RPC integration code, but these shouldn't pose any problem to either extract these into a more generic abstraction layer or to be rewritten not to use these functions at all, because they don't actually use any low-level stuff that's hard to refactor.