add receive_text fn

This commit is contained in:
mii443
2024-08-31 19:02:13 +09:00
parent 3203e4b5c5
commit 753899af32

View File

@ -131,6 +131,10 @@ impl P2P {
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<()> {
self.peer_connection.lock().await.set_remote_description(Self::decode_description(answer, compress)?).await.context("Failed to set answer")
}