lucaspoffo / renet

Server/Client network library for multiplayer games with authentication and connection management made with Rust
Apache License 2.0
620 stars 65 forks source link

Allow NetcodeServer to manage connections from multiple sockets #150

Closed UkoeHB closed 2 months ago

UkoeHB commented 4 months ago

Builds off #149 to allow NetcodeServerTransport to internally manage multiple TransportSockets. This is done by 'domain-separating' the client address space between each socket with a 'socket id'. It is important that sockets don't have overlapping address spaces so the netcode protocol can properly enforce connection invariants.

With this PR, you can have a UdpSocket and WebTransport socket providing packets to the same NetcodeServer, which makes it safe for clients to switch sockets mid-game! If you don't share NetcodeServer then it is not safe to allow socket switching (without some hairy and hard-to-validate engineering) because it is not possible/easy to enforce that a client only has one connection to the server.

At this point I don't have high hopes for these PRs to be merged, but I am presenting them nevertheless.

UkoeHB commented 2 months ago

Closing this as implemented in renet2.