[−][src]Crate laminar
Laminar semi-reliable UDP protocol for multiplayer games. This library implements wraps around a UDP and provides light weight stream based interface that provides certain guarantees like reliability.
Laminar was designed to be used within the Amethyst game engine.
Concepts
This library is mostly based off of Gaffer on Games and shares features with RakNet. The idea is to provide a low level UDP protocol that supports the use cases of video games that require multilayer features. The library itself provides a few low level types of packets that provides different types of guarantees. The most basic are unreliable and reliable packets. This generally correlates to state update packets that do not require to be synced, meaning the packet can get dropped without harm to the game. The other is used for example score updates, where you want to make sure that the data is received on the other end even in case of a packet drop. For more information, read the projects README.md
Example
extern crate laminar; use laminar::{Packet, net::UdpSocket}; use laminar::config::NetworkConfig; use std::net::Ipv4Addr; fn main() { let addr = "127.0.0.1:12345".parse().unwrap(); let mut socket = UdpSocket::bind(addr, NetworkConfig::default()).unwrap(); let data = "example data".as_bytes(); let packet: Packet = Packet::reliable_unordered(addr, data.to_vec()); socket.send(&packet).unwrap(); let data = socket.recv().unwrap(); println!("{:?}", data); }
Re-exports
pub use config::NetworkConfig; |
Modules
config |
Contains networking related configuration |
error |
All internal error handling logic |
net |
Networking modules |
Structs
Packet |
This is a user friendly packet containing the payload from the packet and the endpoint from where it came. |
ProtocolVersion |
Wrapper to provide some functions to perform with the current protocol version. |
Enums
DeliveryMethod |
This enum defines on how an packet would be delivered to the other side. |
Event |
Events that are generated in response to a change in state of the connected client |