We have a server at least #3

Merged
PlexSheep merged 14 commits from devel into master 2024-01-19 16:40:16 +01:00
1 changed files with 11 additions and 4 deletions
Showing only changes of commit a11618add4 - Show all commits

View File

@ -43,20 +43,27 @@ impl Server {
loop { loop {
self.work.poll(&mut self.events, self.timeout)?; self.work.poll(&mut self.events, self.timeout)?;
for event in self.events.iter() { for event in self.events.iter() {
// self.pool.execute(|| {
let result = self.handle_event(event); let result = self.handle_event(event);
if let Err(err) = result { if let Err(err) = result {
error!("Error while handling server event {:?}: {:?}", event, err); error!("Error while handling server event {:?}: {:?}", event, err);
} }
// });
} }
} }
} }
fn handle_event(&self, event: &Event) -> Result<()> { fn handle_event(&self, event: &Event) -> Result<()> {
dbg!(event); dbg!(event);
let _connection = self.server.accept()?; let connection = match self.server.accept() {
Ok(c) => c,
Err(err) => {
error!("error while handling connection: {:?}", err);
return Err(err.into());
}
};
self.pool.execute(move|| {
dbg!(connection);
info!("received a connection!"); info!("received a connection!");
});
Ok(()) Ok(())
} }
} }