Add a counter for the number of clients

This commit is contained in:
QuantumEntangledAndy committed 2023-09-28 13:00:37 +07:00
1 parent daf44fe1c2
commit 8bdb8ef1bd
2 files changed
+15

No files matched your search

+4
View File
@@ -140,6 +140,10 @@ impl Permit {
.await?;
Ok(())
}
pub(crate) fn get_counter(&self) -> WatchReceiver<u32> {
self.value.clone()
}
}
impl Drop for Permit {
+11
View File
@@ -688,6 +688,17 @@ async fn stream_main(
AnyResult::Ok(())
});
// Task to just report the number of clients for debug purposes
let counter = client_counter.create_deactivated().await?;
let mut cur_count = 0;
let thread_name = name.clone();
set.spawn(async move {
loop {
cur_count = *counter.get_counter().wait_for(|v| v != &cur_count).await?;
log::debug!("{thread_name}: Number of rtsp clients: {cur_count}");
}
});
// This runs the actual stream.
// The select will restart if the stream's config updates
log::debug!("{}: Stream Activated", &name);