aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenauxg <19689618+Henauxg@users.noreply.github.com>2023-01-20 14:00:19 +0100
committerHenauxg <19689618+Henauxg@users.noreply.github.com>2023-01-20 14:00:19 +0100
commit6875447a5f9bff0e832d632324f25685cb069951 (patch)
treee267971cd3124e3d83d750dc341ae01e5778c16e
parenta03001bb9913bd7e7bc1a30eb811104810331c39 (diff)
[client & server] Add some doc string
-rw-r--r--src/client.rs6
-rw-r--r--src/server.rs6
2 files changed, 11 insertions, 1 deletions
diff --git a/src/client.rs b/src/client.rs
index 38176d0..a7b03a9 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -184,7 +184,11 @@ impl Client {
self.default_connection_id
}
- /// Close a specific connection. Removes it from the client. This may fail if no [Connection] if found for connection_id, or if the [Connection] is already closed.
+ /// Close a specific connection. Removes it from the client.
+ ///
+ /// Closign a connection immediately prevents new messages from being sent on the connection and signal it to closes all its background tasks. Before trully closing, the connection will wait for all buffered messages in all its opened channels to be properly sent according to their respective channel type.
+ ///
+ /// This may fail if no [Connection] if found for connection_id, or if the [Connection] is already closed.
pub fn close_connection(&mut self, connection_id: ConnectionId) -> Result<(), QuinnetError> {
match self.connections.remove(&connection_id) {
Some(mut connection) => {
diff --git a/src/server.rs b/src/server.rs
index e95474e..0640637 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -464,6 +464,11 @@ impl Endpoint {
}
}
+ /// Disconnect a specific client. Removes it from the server.
+ ///
+ /// Disconnecting a client immediately prevents new messages from being sent on its connection and signal the underlying connection to closes all its background tasks. Before trully closing, the connection will wait for all buffered messages in all its opened channels to be properly sent according to their respective channel type.
+ ///
+ /// This may fail if no client if found for client_id, or if the client is already disconnected.
pub fn disconnect_client(&mut self, client_id: ClientId) -> Result<(), QuinnetError> {
match self.clients.remove(&client_id) {
Some(client_connection) => match client_connection.close_sender.send(()) {
@@ -485,6 +490,7 @@ impl Endpoint {
}
}
+ /// Calls disconnect_client on all onnected clients
pub fn disconnect_all_clients(&mut self) -> Result<(), QuinnetError> {
for client_id in self.clients.keys().cloned().collect::<Vec<ClientId>>() {
self.disconnect_client(client_id)?;