diff --git a/libs/socket_cs/src/udp.rs b/libs/socket_cs/src/udp.rs index 73bdb77e4..aef64fd65 100644 --- a/libs/socket_cs/src/udp.rs +++ b/libs/socket_cs/src/udp.rs @@ -5,10 +5,7 @@ use hbb_common::{ udp::FramedSocket, ResultType, }; -use std::collections::HashMap; -use std::future::Future; -use std::net::SocketAddr; -use std::sync::Arc; +use std::{collections::HashMap, future::Future, net::SocketAddr, sync::Arc}; /// Simple udp server pub struct Server { diff --git a/src/server/udp.rs b/src/server/udp.rs index 7eeea6f26..7ff828485 100644 --- a/src/server/udp.rs +++ b/src/server/udp.rs @@ -29,7 +29,7 @@ pub mod discovery { use super::get_peer_info; use crate::ipc; use hbb_common::{ - config::{Config, PeerConfig, PeerInfoSerde, SERVER_UDP_PORT}, + config::{PeerConfig, PeerInfoSerde, SERVER_UDP_PORT}, discovery_proto::{Discovery as DiscoveryProto, DiscoveryBack as DiscoveryBackProto}, log, protobuf, tokio, ResultType, }; @@ -44,6 +44,9 @@ pub mod discovery { } } + /// process sicovery bakc(response) + /// 1. update current peers. + /// 2. notify index window to udpate recent sessions. fn process_discovery_back(info: DiscoveryBackProto) { let mut config = PeerConfig::load(info.id.as_str()); @@ -70,6 +73,7 @@ pub mod discovery { }); } + /// launch lan discover when user click "discover" button. pub fn launch_lan_discover() { std::thread::spawn(move || { if let Err(e) = lan_discover() { @@ -95,6 +99,7 @@ pub mod discovery { pub(super) async fn handle_discovery(handlers: UdpHandlers) -> UdpHandlers { let info = get_discovery_back_info().await; handlers + // handle discover request .handle( CMD_DISCOVERY.as_bytes().to_vec(), Box::new(HandlerDiscovery::new( @@ -103,6 +108,7 @@ pub mod discovery { info, )), ) + // handle discover back(response) .handle( CMD_DISCOVERY_BACK.as_bytes().to_vec(), Box::new(HandlerDiscoveryBack::new(process_discovery_back)), diff --git a/src/ui/index.tis b/src/ui/index.tis index 903a1a030..16c6786be 100644 --- a/src/ui/index.tis +++ b/src/ui/index.tis @@ -51,7 +51,7 @@ class RecentSessions: Reactor.Component { sessions = sessions.map(this.getSession); return
RECENT SESSIONS
- + { false && }
{sessions}