-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; | ||
|
||
|
@@ -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(()) | ||
} |