Provides utilities for setting up renet2 servers and clients.
Server workflow
- Define a
GameServerSetupConfigfor your server. - Collect the number of clients who will use each connection type into
ClientCounts. - Make a
ConnectionConfigwith the channels for your renet2 connection with clients.- This should match the
ConnectionConfigsused by your clients. - If using the
bevy_replicon_renet2crate, then the channels can be obtained fromRepliconChannels. UseConnectionConfigs::from_channels.
- This should match the
- Call
setup_combo_renet2_serverto getRenetServe,NetcodeServerTransport, andConnectMetas.- If using the
bevyfeature, callsetup_combo_renet2_server_in_bevyinstead.
- If using the
- Drive the
RenetServerandNetcodeServerTransportforward.- This is handled automatically if you use the
bevy_renet2crate.
- This is handled automatically if you use the
- Use
ConnectMetasto createServerConnectTokensfor clients based on theirConnectionTypes.- These 'metas' can be stored on a separate server from the game server.
In-memory connections
Add in-memory clients to ClientCounts and follow the above steps.
WebTransport certificates
This crate uses self-signed certificates to set up webtransport servers. Self-signed certificates only last 2 weeks, so if your game server lives longer than that and you need webtransport, then you should use the underlying renet2/renet2_netcode APIs instead of this crate.
Self-signed certificates are not supported everywhere. We assume clients will fall back to websockets if webtransport with self-signed certs are unavailable. ConnectionType::inferred will detect the correct connection type for each client.
WebSocket TLS
Websocket TLS requires a domain name in GameServerSetupConfig and the locations of PEM-encoded cert files (e.g. generated with Let's Encrypt). This crate uses rustls for TLS instead of native-tls so you don't need to install OpenSSL on every machine you deploy to.
If no rustls::crypto::CryptoProvider is installed, then rustls::crypto::ring::default_provider().install_default() will be called when setting up a websocket server.
tokio
A default tokio runtime is set up if a server needs a webtransport or websocket socket.
Client workflow
- Send your
ConnectionTypeto the game backend.- Use
ConnectionType::inferredto construct it.
- Use
- Receive
ServerConnectTokenfrom the game backend. - Make a connect pack with
ClientConnectPack::new. - Make a
ConnectionConfigwith the channels for your renet2 connection with the server.- This should match the
ConnectionConfigused by the server. - If using the
bevy_replicon_renet2crate, then the channels can be obtained fromRepliconChannels. UseConnectionConfigs::from_channels.
- This should match the
- Call
setup_renet2_clientto getRenetClientandNetcodeClientTransport.- If using the
bevyfeature, callsetup_renet2_client_in_bevyinstead.
- If using the
- Drive the
RenetClientandNetcodeClientTransportforward.- This is handled automatically if you use the
bevy_renet2crate.
- This is handled automatically if you use the
In-memory connections
Receive ServerConnectToken::Memory from the local server (running in-memory with the client) and follow the above steps.