Crates.io | mudbase_server |
lib.rs | mudbase_server |
version | 0.1.0 |
source | src |
created_at | 2022-03-03 02:26:59.862301 |
updated_at | 2022-03-03 02:26:59.862301 |
description | A library for configuring and running a simple TCP server |
homepage | https://github.com/DrVonDevious/mudbase |
repository | https://github.com/DrVonDevious/mudbase |
max_upload_size | |
id | 542701 |
size | 20,349 |
mudbase_server is a sub-module of the Mudbase library that makes it
easier to start and configure a simple TCP server.
use mudbase::server::{ ServerHandler, Sessions, SessionsType };
struct Server {
sessions: SessionsType,
}
impl Server {
fn new() -> Self {
Self {
sessions: Sessions::new(),
}
}
}
impl ServerHandler for Server {
fn handle_message(message: &str, address: &str) {
print!("{} says: {}", address, message);
}
}
fn main() {
let server = Server::new();
let listener = server.start("127.0.0.1", "7878");
let sessions = server.sessions.clone();
server.listen(listener, sessions);
}