aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/server.rs b/src/server.rs
index 7586d25..fbbcdbf 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -8,6 +8,7 @@ use std::{
use bevy::prelude::*;
use bytes::Bytes;
use quinn::{ConnectionError, Endpoint as QuinnEndpoint, ServerConfig};
+use quinn_proto::ConnectionStats;
use serde::Deserialize;
use tokio::{
runtime,
@@ -491,6 +492,14 @@ impl Endpoint {
Ok(())
}
+ /// Returns statistics about a client if connected.
+ pub fn stats(&self, client_id: ClientId) -> Option<ConnectionStats> {
+ match &self.clients.get(&client_id) {
+ Some(client) => Some(client.connection_handle.stats()),
+ None => None,
+ }
+ }
+
/// Opens a channel of the requested [ChannelType] and returns its [ChannelId].
///
/// By default, when starting an [Endpoint], Quinnet creates 1 channel instance of each [ChannelType], each with their own [ChannelId]. Among those, there is a `default` channel which will be used when you don't specify the channel. At startup, this default channel is a [ChannelType::OrderedReliable] channel.