From dd0c0cf42aa77272df3511199f77d50bac9d93ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 27 Apr 2025 21:11:18 +0300 Subject: [PATCH] fix: :zap: ice candidate string transformation --- client/src/gui.rs | 6 ++++++ client/src/signal.rs | 2 +- client/src/webrtc.rs | 6 +----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/client/src/gui.rs b/client/src/gui.rs index fa40669..2b98af3 100644 --- a/client/src/gui.rs +++ b/client/src/gui.rs @@ -5,6 +5,7 @@ use leptos::{ prelude::{OnAttribute, Read, Show, ShowProps, ToChildren}, server::LocalResource, }; +use wasm_bindgen_futures::spawn_local; use crate::{media::audio, webrtc::WebRTC}; @@ -22,7 +23,12 @@ pub fn app() -> impl IntoView { let webrtc_offer = webrtc.clone(); let offer_button = button() .on(leptos::ev::click, move |_| { + let webrtc_offer = webrtc_offer.clone(); log!("{:#?}", webrtc_offer.get_status()); + spawn_local(async move { + let offer_result = webrtc_offer.offer().await; + log!("Offer Result Is = {:#?}", offer_result); + }); }) .child("Offer"); diff --git a/client/src/signal.rs b/client/src/signal.rs index bd79e13..25618bf 100644 --- a/client/src/signal.rs +++ b/client/src/signal.rs @@ -7,7 +7,7 @@ use web_sys::{ wasm_bindgen::{JsCast, prelude::Closure}, }; -static SIGNALLING_ADDRESS: &str = "ws://192.168.1.3:4546"; +static SIGNALLING_ADDRESS: &str = "http://192.168.1.3:4546/signal"; thread_local! { static WEBSOCKET: WebSocket = SignallingChannel::init().unwrap(); diff --git a/client/src/webrtc.rs b/client/src/webrtc.rs index 700afa9..12db646 100644 --- a/client/src/webrtc.rs +++ b/client/src/webrtc.rs @@ -44,7 +44,7 @@ impl WebRTC { let on_ice_candidate = Closure::::new( move |peer_connection_ice_event: RtcPeerConnectionIceEvent| { if let Some(candidate) = peer_connection_ice_event.candidate() { - if let Err(err_val) = send_ice_candidate(&candidate.as_string().unwrap()) { + if let Err(err_val) = send_ice_candidate(&candidate.candidate()) { log!("Error: Send ICE Candidate | {}", err_val); } } @@ -104,14 +104,12 @@ impl WebRTC { } pub async fn offer(&self) -> Result<(), Error> { - log!("Offer Function"); let offer_promise = self.peer_connection.create_offer(); match JsFuture::from(offer_promise) .await .map_err(|_| Error::WebRTCOffer) { Ok(offer) => { - log!("Offer Created"); let offer_session_description_protocol = Reflect::get(&offer, &JsValue::from_str("sdp")) .map_err(|_| Error::WebRTCSessionDescriptionProtocol)?; @@ -129,9 +127,7 @@ impl WebRTC { .await .map_err(|_| Error::WebRTCSetLocalDescription)?; - log!("Before Sent Offer"); send_offer(&offer_session_description_protocol)?; - log!("After Sent Offer"); if let Ok(received_answer) = receive_answer().await { let answer = RtcSessionDescriptionInit::new(RtcSdpType::Answer); answer.set_sdp(&received_answer.get_data());