async-datachannel

Crates.ioasync-datachannel
lib.rsasync-datachannel
version0.4.0
sourcesrc
created_at2021-09-14 20:49:34.069282
updated_at2022-11-29 08:15:37.924725
descriptionAsync Wrapper for datachannel
homepagehttps://github.com/wngr/async-datachannel
repositoryhttps://github.com/wngr/async-datachannel
max_upload_size
id451461
size56,024
Oliver Wangler (wngr)

documentation

https://docs.rs/async-datachannel

README

async-datachannel

License Cargo Documentation

Async wrapper for the datachannel crate. For a complete example check the examples directory.

Note that this crate currently is made to work only with the tokio runtime. If you're interested in supporting other runtimes, let me know.

Quickstart

use async_datachannel::{Message, PeerConnection, PeerId, 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(&conf, (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.

Commit count: 33

cargo fmt