Start rewrite, get layers working

This commit is contained in:
Michael Mikovsky
2025-06-09 12:37:49 -06:00
parent 6ac1b5214e
commit a148e4e0a8
31 changed files with 527 additions and 792 deletions
+37
View File
@@ -0,0 +1,37 @@
use std::{net::SocketAddr, thread};
use crate::{
Error,
layers::LayerConfig,
networkers::{Connection, ServerTrait, TCPConnection, TCPServer, run_listener},
};
pub struct Node;
impl Node {
pub fn run(addr: SocketAddr) -> Result<(), Error> {
let layers = vec![LayerConfig::Handshake, LayerConfig::Base64];
run_listener(
TCPServer::bind(&addr)?,
layers,
|connection: Box<dyn Connection + Send + 'static>| {
thread::spawn(move || {
let mut connection = connection;
loop {
if let Ok(data) = connection.read() {
if !connection.is_alive() {
warn!("{} Disconnected!", connection.get_info());
break;
}
println!("Data: {}", data);
}
}
});
},
);
Ok(())
}
}