Add a counter for the number of clients
This commit is contained in:
2 files changed
+15
No files matched your search
@@ -140,6 +140,10 @@ impl Permit {
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn get_counter(&self) -> WatchReceiver<u32> {
|
||||
self.value.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Permit {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user