#data-channel #web-rtc #async #wasm #api-wrapper

async-datachannel-wasm

Async Wrapper for WebRTC datachannel in the browser environment

5 releases

0.2.1 Nov 29, 2022
0.2.0 Mar 9, 2022
0.1.2 Sep 22, 2021
0.1.1 Sep 21, 2021
0.1.0 Sep 21, 2021

#784 in Concurrency

Download history 90/week @ 2024-03-09 90/week @ 2024-03-16 102/week @ 2024-03-23 92/week @ 2024-03-30 41/week @ 2024-04-06 37/week @ 2024-04-13 55/week @ 2024-04-20 41/week @ 2024-04-27 55/week @ 2024-05-04 80/week @ 2024-05-11 78/week @ 2024-05-18 43/week @ 2024-05-25 75/week @ 2024-06-01 70/week @ 2024-06-08 7/week @ 2024-06-15 6/week @ 2024-06-22

162 downloads per month
Used in libp2p-webrtc

Apache-2.0 OR MIT

22KB
359 lines

async-datachannel-wasm

License Cargo Documentation

Async wrapper API for browser provided WebRTC API.


Quickstart

use async_datachannel_wasm::{Message, PeerConnection, RtcConfig};
use futures::io::{AsyncReadExt, AsyncWriteExt, channel::mpsc};

let ice_servers = vec!["stun:stun.l.google.com:19302"];
let conf = RtcConfig::new(&ice_servers);
let (tx_sig_outbound, mut rx_sig_outbound) = mpsc::channel(32);
let (tx_sig_inbound, rx_sig_inbound) = mpsc::channel(32);
let listener = PeerConnection::new(ice_servers, (tx_sig_outbound, rx_sig_inbound))?;

// TODO: Wire up `tx_sig_inbound` and `rx_sig_outbound` to a signalling
// mechanism.

let mut dc = listener.dial("Hangout").await?;
dc.write(b"Hello").await?;

let mut buf = vec![0; 32];
let n = dc.read(&mut buf).await?;
assert_eq!(b"World", &buf[..n]);

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~7.5–10MB
~193K SLoC