rustdesk
2021-12-24 19:13:11 +08:00
parent 885d8a4586
commit 4703a7d332
7 changed files with 52 additions and 49 deletions

View File

@@ -6,7 +6,7 @@ fn main() {
thread::sleep(Duration::from_secs(2));
let mut enigo = Enigo::new();
enigo.key_down(Key::Layout('a'));
enigo.key_down(Key::Layout('a')).ok();
thread::sleep(Duration::from_secs(1));
enigo.key_up(Key::Layout('a'));
}

View File

@@ -10,7 +10,7 @@ fn main() {
enigo.key_sequence("Hello World! here is a lot of text ❤️");
// select all
enigo.key_down(Key::Control);
enigo.key_down(Key::Control).ok();
enigo.key_click(Key::Layout('a'));
enigo.key_up(Key::Control);
}

View File

@@ -11,7 +11,7 @@ fn main() {
enigo.mouse_move_to(500, 200);
thread::sleep(wait_time);
enigo.mouse_down(MouseButton::Left);
enigo.mouse_down(MouseButton::Left).ok();
thread::sleep(wait_time);
enigo.mouse_move_relative(100, 100);

View File

@@ -16,7 +16,7 @@ fn main() {
println!("{:?}", time);
// select all
enigo.key_down(Key::Control);
enigo.key_down(Key::Control).ok();
enigo.key_click(Key::Layout('a'));
enigo.key_up(Key::Control);
}

View File

@@ -10,7 +10,7 @@ use std::{
use tokio::net::{lookup_host, TcpListener, TcpSocket, TcpStream, ToSocketAddrs};
use tokio_util::codec::Framed;
pub struct FramedStream(Framed<TcpStream, BytesCodec>, Option<(Key, u64, u64)>);
pub struct FramedStream(Framed<TcpStream, BytesCodec>, Option<(Key, u64, u64)>, u64);
impl Deref for FramedStream {
type Target = Framed<TcpStream, BytesCodec>;
@@ -56,14 +56,18 @@ impl FramedStream {
new_socket(local_addr, true)?.connect(remote_addr),
)
.await??;
return Ok(Self(Framed::new(stream, BytesCodec::new()), None));
return Ok(Self(Framed::new(stream, BytesCodec::new()), None, 0));
}
}
bail!("could not resolve to any address");
}
pub fn set_send_timeout(&mut self, ms: u64) {
self.2 = ms;
}
pub fn from(stream: TcpStream) -> Self {
Self(Framed::new(stream, BytesCodec::new()), None)
Self(Framed::new(stream, BytesCodec::new()), None, 0)
}
pub fn set_raw(&mut self) {
@@ -88,12 +92,17 @@ impl FramedStream {
let nonce = Self::get_nonce(key.1);
msg = secretbox::seal(&msg, &nonce, &key.0);
}
self.0.send(bytes::Bytes::from(msg)).await?;
self.send_bytes(bytes::Bytes::from(msg)).await?;
Ok(())
}
#[inline]
pub async fn send_bytes(&mut self, bytes: Bytes) -> ResultType<()> {
self.0.send(bytes).await?;
if self.2 > 0 {
super::timeout(self.2, self.0.send(bytes)).await??;
} else {
self.0.send(bytes).await?;
}
Ok(())
}

View File

@@ -43,7 +43,6 @@ struct Args {
flag_time: Option<u64>,
flag_fps: u64,
flag_bv: u32,
flag_ba: u32,
}
#[derive(Debug, serde::Deserialize)]