| Crates.io | renet2_setup |
| lib.rs | renet2_setup |
| version | 0.10.0 |
| created_at | 2025-02-07 06:10:15.586326+00 |
| updated_at | 2025-06-20 23:19:41.280174+00 |
| description | Setup utilities for renet2 |
| homepage | |
| repository | https://github.com/UkoeHB/renet2 |
| max_upload_size | |
| id | 1546546 |
| size | 142,287 |
Provides utilities for setting up renet2 servers and clients.
GameServerSetupConfig for your server.ClientCounts.
ConnectionType to aid in this (see the client workflow below).ConnectionConfig with the channels for your renet2 connection with clients.
ConnectionConfig used by your clients.bevy_replicon_renet2 crate, then you must obtain replicon-specific channels from RepliconChannels. Other channels must be constructed separately. Use ConnectionConfigs::from_channels.setup_combo_renet2_server to get RenetServer, NetcodeServerTransport, and ConnectMetas.
bevy feature, call setup_combo_renet2_server_in_bevy instead.RenetServer and NetcodeServerTransport forward.
bevy_renet2 or bevy_replicon_renet2 crates.ConnectMetas to create ServerConnectTokens for clients based on their ConnectionTypes (see the client workflow below).
Add in-memory clients to ClientCounts and follow the above steps.
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 best connection type for each client.
Websocket TLS requires a domain name in GameServerSetupConfig and the locations of PEM-encoded cert files (e.g. generated with Let's Encrypt). You must specify the ws-native-tls or ws-rustls feature in addition to ws_server_transport in order to use websocket certs. Note that ws-native-tls requires OpenSSL, which may need to be installed separately on your server host.
If using ws-rustls and no rustls::crypto::CryptoProvider is installed, then rustls::crypto::ring::default_provider().install_default() will be called when setting up a websocket server.
tokioA default tokio runtime is set up if a server needs webtransport or websockets. If you want to reuse that runtime for something else like a webserver, use enfync::builtin::native::TokioHandle::adopt_or_default to get a handle to it for spawning tokio tasks.
ConnectionType to the game backend.
ConnectionType::inferred to construct it.ServerConnectToken from the game backend.ClientConnectPack::new.ConnectionConfig with the channels for your renet2 connection with the server.
ConnectionConfig used by the server.bevy_replicon_renet2 crate, then you must obtain replicon-specific channels from RepliconChannels. Other channels must be constructed separately. Use ConnectionConfigs::from_channels.setup_renet2_client to get RenetClient and NetcodeClientTransport.
bevy feature, call setup_renet2_client_in_bevy instead.RenetClient and NetcodeClientTransport forward.
bevy_renet2 or bevy_replicon_renet2 crates.Receive ServerConnectToken::Memory from the local server (running in-memory with the client) and follow the above steps.