presentation: width: 1024
#[derive(Debug, Default)]
pub struct Server<T: SubListTrait> {
state: Arc<Mutex<ServerState<T>>>,
}
#[derive(Debug, Default)]
pub struct ServerState<T: SubListTrait> {
clients: HashMap<u64, Arc<Mutex<ClientMessageSender>>>,
pub sublist: T,
pub gen_cid: u64,
}
在task之间传送
impl<T: SubListTrait + Send + 'static> Server<T> {
}
new_client则是调用Client的process_connection 创建Client实例, 并保存.
impl<T: SubListTrait + Send + 'static> Server<T> {
pub async fn start(&self) -> Result<(), Box<dyn Error>> {
}
async fn new_client(&self, conn: TcpStream) {
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
println!("server start..");
let s: Server<SimpleSubList> = Server::default();
s.start().await
}