Crates.io | netstack |
lib.rs | netstack |
version | 0.3.0 |
source | src |
created_at | 2020-03-23 15:44:37.16056 |
updated_at | 2020-04-05 14:39:31.532397 |
description | A batteries included networking crate for games. |
homepage | |
repository | https://github.com/Vengarioth/netstack |
max_upload_size | |
id | 221780 |
size | 68,385 |
A batteries included networking crate for games.
[dependencies]
netstack = "0.3.0"
Documentation (work in progress)
If you have suggestions, miss features or just want to get in touch, you can open issues in this repository or get a hold of me on twitter.
To effectively use netstack in production you need a secure channel to exchange an initial secret and connection token. It is recommended to use https for this, but it's up to you. The examples use a http server.
(☑️ means implemented, 🚧 means planned or under development)
Transports based on io_uring
, IOCP
or epoll
are out of scope right now.
This crate does not implement retransmission based on acks and timeouts. Games have other ways of achieving reliability, mostly because information is already outdated by the time any timeout based mechanism would detect the lost packet.
FPS for instance send player input for the last couple of frames with every packet, so when one gets lost on the wire the next packet fills in the gap.
Compression of game state from the server to the client is usually based on the last packet acknowledged by the client. Use the MessageAcknowledged
event and the sequence number returned by send
for this.
See the examples directory for a client/server example, use the commands to run them:
cargo run -p server
cargo run -p client
Netstack comes with a work in progress derive macro for structs (and later enums).
#[derive(Debug, Serialize, Deserialize)]
pub struct Greeting {
pub id: u32,
pub to: String,
pub message: String,
}