mirror of
https://github.com/mii443/rs-easy-p2p.git
synced 2025-12-03 03:08:21 +00:00
add receive_text fn
This commit is contained in:
@@ -131,6 +131,10 @@ impl P2P {
|
|||||||
self.receive_data.lock().await.recv().await
|
self.receive_data.lock().await.recv().await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn receive_text(&mut self) -> Result<String> {
|
||||||
|
String::from_utf8(self.receive_data.lock().await.recv().await.context("Failed to receive data")?.to_vec()).context("Failed to convert")
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn set_answer(&mut self, answer: &str, compress: bool) -> Result<()> {
|
pub async fn set_answer(&mut self, answer: &str, compress: bool) -> Result<()> {
|
||||||
self.peer_connection.lock().await.set_remote_description(Self::decode_description(answer, compress)?).await.context("Failed to set answer")
|
self.peer_connection.lock().await.set_remote_description(Self::decode_description(answer, compress)?).await.context("Failed to set answer")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user