#[cfg(target_arch = "wasm32")]
pub mod wasm {
use wasm_bindgen::prelude::*;
use web_sys::{RtcConfiguration, RtcDataChannel, RtcPeerConnection};
#[wasm_bindgen]
#[doc(hidden)]
pub struct WasmConnection {
pc: RtcPeerConnection,
}
#[wasm_bindgen]
impl WasmConnection {
#[wasm_bindgen(constructor)]
pub fn new() -> Result<WasmConnection, JsValue> {
let config = RtcConfiguration::new();
let pc = RtcPeerConnection::new_with_configuration(&config)?;
Ok(Self { pc })
}
pub fn create_data_channel(&self, label: &str) -> RtcDataChannel {
self.pc.create_data_channel(label)
}
}
}