Crates.io | udp_netmsg |
lib.rs | udp_netmsg |
version | 0.2.0 |
source | src |
created_at | 2019-05-09 00:39:56.700755 |
updated_at | 2020-10-25 23:59:00.285423 |
description | A low cost abstraction for sending and receiving udp datagrams. Gives ability to send and receive datagrams defined by custom structs in a simple way |
homepage | https://github.com/Javagedes/udp_netmsg |
repository | https://github.com/Javagedes/udp_netmsg |
max_upload_size | |
id | 132920 |
size | 44,468 |
If you're looking to easily send and receive Udp Messages then this crate is perfect for you. This gives you the ability to define your own Net Messages by simply creating a struct and implementing a trait.
If you have suggestions or questions for this crate, raise an issue!
use udp_netmsg::prelude::*;
use serde::{Serialize, Deserialize};
use std::{thread, time};
#[derive(Serialize, Deserialize)]
struct UpdatePos {
pub x: f32,
pub y: f32,
pub z: f32
}
fn main() {
let net_msg = Builder::init().start::<JSON>().unwrap();
let pos = UpdatePos{x: 15f32, y: 15f32, z: 15f32};
net_msg.send(pos, String::from("127.0.0.1:39507")).unwrap();
thread::sleep(time::Duration::from_millis(100));
net_msg.get::<UpdatePos>().unwrap();
}
More examples found here.