mirror of
https://github.com/rustdesk/hbb_common.git
synced 2026-02-16 02:20:43 +00:00
remove unwraps
This commit is contained in:
@@ -102,13 +102,15 @@ async fn read_loop(mut stream: hbb_common::Stream) -> Result<()> {
|
|||||||
println!("WebRTC stream closed; Exit the read_loop");
|
println!("WebRTC stream closed; Exit the read_loop");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
if res.is_err() {
|
match res {
|
||||||
println!("WebRTC stream read error: {}; Exit the read_loop", res.err().unwrap());
|
Err(e) => {
|
||||||
return Ok(());
|
println!("WebRTC stream read error: {}; Exit the read_loop", e);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
Ok(data) => {
|
||||||
|
println!("Message from stream: {}", String::from_utf8(data.to_vec())?);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
println!("Message from stream: {}",
|
|
||||||
String::from_utf8(res.unwrap().to_vec())?
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,19 @@ impl WebRTCStream {
|
|||||||
let contains = lock.contains_key(&key);
|
let contains = lock.contains_key(&key);
|
||||||
if contains {
|
if contains {
|
||||||
log::debug!("Start webrtc with cached peer");
|
log::debug!("Start webrtc with cached peer");
|
||||||
return Ok(lock.get(&key).unwrap().clone());
|
return Ok(lock[&key].clone());
|
||||||
|
}
|
||||||
|
// ...existing code...
|
||||||
|
Self::get_remote_offer(remote_endpoint)?
|
||||||
|
};
|
||||||
|
|
||||||
|
let key = remote_offer.clone();
|
||||||
|
let mut lock = SESSIONS.lock().await;
|
||||||
|
if let Some(cached_stream) = lock.get(&key) {
|
||||||
|
if !key.is_empty() {
|
||||||
|
log::debug!("Start webrtc with cached peer");
|
||||||
|
return Ok(cached_stream.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a SettingEngine and enable Detach
|
// Create a SettingEngine and enable Detach
|
||||||
|
|||||||
Reference in New Issue
Block a user