Crates.io | lyanne |
lib.rs | lyanne |
version | 0.6.2 |
source | src |
created_at | 2024-09-08 10:30:15.815015 |
updated_at | 2024-09-28 21:40:27.589327 |
description | Tick-based communication library for server-client architectures. |
homepage | |
repository | https://github.com/Robsutar/lyanne/ |
max_upload_size | |
id | 1367974 |
size | 958,890 |
Efficient, tick-oriented communication library for server-client architectures.
rt_async_executor
, rt_async_std
, rt_bevy
, rt_smol
or rt_tokio
runtime environments for seamless integration with your ecosystem.sd_bincode
feature for efficient packet serialization and deserialization.auth_tls
feature using rustls for TLS encryption, or opt for auth_tcp
with a reverse proxy like NGINX for encrypted TCP communication. WARNING: Further testing is required to validate the security of authenticators.Adding lyanne dependency in server:
[dependencies]
lyanne = { version = "0.5", features = [
"rt_smol", # We need one runtime.
"sd_bincode", # Serde + Bincode will help our packet serialization/deserialization.
"server", # Server exclusive feature.
] }
# Our runtime.
smol = "^2.0.0"
# Our serializer.
serde = { version = "^1.0.0", features = ["derive"] }
bincode = "^1.0.0"
Adding lyanne dependency in client:
[dependencies]
lyanne = { version = "0.5", features = [
# ...
"client", # Same as the server, but using "client" instead of "server".
] }
Creating packets with sd_bincode
:
use lyanne::packets::Packet;
use serde::{Deserialize, Serialize};
#[derive(Packet, Deserialize, Serialize, Debug)]
struct HelloPacket {
player_name: String,
}
#[derive(Packet, Deserialize, Serialize, Debug)]
struct MessagePacket {
message: String,
}
Sending packet to clients:
use lyanne::{server::*};
// Use your shared crate with the packets.
use crate::packets::MessagePacket;
fn inside_tick(server: &Server) {
let packet = MessagePacket {
message: "Foo!".to_owned(),
};
for client in server.connected_clients_iter() {
server.send_packet(&client, &packet);
}
}
Sending packet to server:
use lyanne::{client::*};
// Use your shared crate with the packets.
use crate::packets::MessagePacket;
fn inside_tick(client: &Client) {
let packet = MessagePacket {
message: "Bar?".to_owned(),
};
client.send_packet(&packet);
}
See more complete examples in examples folder, and in crate documentation.