main
_ 2020-10-27 01:55:47 +00:00
parent 394345cfe2
commit a8caae68c3
2 changed files with 16 additions and 3 deletions

View File

@ -21,9 +21,7 @@ use tokio::{
time::delay_for,
};
mod watcher;
use watcher::Watchers;
use ptth::watcher::Watchers;
#[derive (Clone)]
enum Message {
@ -60,6 +58,17 @@ async fn handle_wake (state: Arc <ServerState>)
status_reply (StatusCode::OK, "ok\n")
}
async fn handle_udp_send () -> Response <Body>
{
use tokio::net::UdpSocket;
let mut sock = UdpSocket::bind (SocketAddr::from (([0,0,0,0], 0))).await.unwrap ();
sock.send_to (b"handle_udp_send\n", SocketAddr::from (([127,0,0,1], 9000u16))).await.unwrap ();
status_reply (StatusCode::OK, "ok\n")
}
async fn handle_all (req: Request <Body>, state: Arc <ServerState>)
-> Result <Response <Body>, Infallible>
{
@ -72,6 +81,9 @@ async fn handle_all (req: Request <Body>, state: Arc <ServerState>)
else if uri == "/wake" {
Ok (handle_wake (state).await)
}
else if uri == "/udp_send" {
Ok (handle_udp_send ().await)
}
else {
Ok (status_reply (StatusCode::OK, "Hi\n"))
}

1
src/lib.rs Normal file
View File

@ -0,0 +1 @@
pub mod watcher;