Skip to content

Commit

Permalink
Implement kill_client
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteOtter committed Jul 22, 2024
1 parent 3d40e13 commit f19e8f8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions isototest/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightTest: Christopher Hock <[email protected]>
// SPDX-License-Identifier: GPL-2.0-or-later

//! # Connection Module
//!
//! This module handles the VncClient and its connection to the VncServer.
use tokio::{self, net::TcpStream};
use vnc::{PixelFormat, VncClient, VncConnector, VncError};

Expand Down Expand Up @@ -52,3 +58,23 @@ pub async fn create_vnc_client(

Ok(vnc)
}

/// Stop VNC engine, release all resources
///
/// # Parameters
///
/// * client: `VncClient` - The client to kill.
///
/// # Returns
///
/// * `Ok(())` - In case the client terminates correctly.
/// * `Err(VncError)` - Escalates the `VncError` upwards, if the `.close()` function of `vnc-rs`
/// returns an error.
pub async fn kill_client(client: VncClient) -> Result<(), VncError> {
match client.close().await {
Ok(_) => {},
Err(e) => return Err(e)
};
drop(client);
Ok(())
}

0 comments on commit f19e8f8

Please sign in to comment.