add counter to keep track of connected clients
This commit is contained in:
parent
c050d8bfb0
commit
3520118336
2 changed files with 5 additions and 5 deletions
|
|
@ -21,6 +21,7 @@ pub type Canvas = u8;
|
|||
pub type Coordinate = u16;
|
||||
|
||||
pub static COUNTER: AtomicU64 = AtomicU64::new(0);
|
||||
pub static CLIENTS: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
pub type AsyncResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use flurry::{
|
|||
flutclient::{FlutClient, ParserTypes},
|
||||
grid::{self, Flut},
|
||||
webapi::WebApiContext,
|
||||
AsyncResult,
|
||||
AsyncResult, CLIENTS,
|
||||
};
|
||||
use futures::never::Never;
|
||||
use tokio::{net::TcpListener, time::interval, try_join};
|
||||
|
|
@ -59,11 +59,10 @@ async fn handle_flut(
|
|||
handles.push(tokio::spawn(async move {
|
||||
let (reader, writer) = socket.split();
|
||||
let mut connection = FlutClient::new(reader, writer, grids);
|
||||
CLIENTS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
let resp = connection.process_socket().await;
|
||||
match resp {
|
||||
Ok(()) => Ok(()),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
CLIENTS.fetch_sub(1, std::sync::atomic::Ordering::Relaxed);
|
||||
resp
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue