feat: rtc peer connection send_offer, receive_offer

This commit is contained in:
Ahmet Kaan Gümüş 2025-04-13 04:55:33 +03:00
parent 0aa65f0f60
commit ffc802eb59
4 changed files with 102 additions and 28 deletions

View file

@ -1,4 +1,5 @@
use leptos::logging::log;
use protocol::RTCSessionOffer;
use wasm_bindgen_futures::JsFuture;
use web_sys::{
RtcConfiguration, RtcIceServer, RtcPeerConnection, RtcSessionDescriptionInit,
@ -6,7 +7,9 @@ use web_sys::{
wasm_bindgen::{JsCast, JsValue},
};
pub async fn offer() {
use crate::signal::send_offer;
pub async fn offer(username: String) {
let ice_server_addresses = vec![JsValue::from("stun:stun.l.google.com:19302")]
.into_iter()
.collect::<Array>();
@ -33,6 +36,12 @@ pub async fn offer() {
.as_string()
.unwrap();
log!("{}", rtc_session_offer);
send_offer(RTCSessionOffer {
username,
rtc_session_offer,
})
.await;
}
pub async fn answer() {}