wasm_p2p 0.1.0

Simple peer-to-peer library for Rust + WASM, built on top of WebRTC
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use wasm_bindgen_futures::JsFuture;
use web_sys::{
    js_sys::{Function, Promise},
    window,
};

pub async fn sleep(ms: i32) {
    let mut callback = |resolve: Function, _| {
        window()
            .unwrap()
            .set_timeout_with_callback_and_timeout_and_arguments_0(&resolve, ms)
            .unwrap();
    };

    let promise = Promise::new(&mut callback);
    JsFuture::from(promise).await.unwrap();
}