Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 4aa4f5b

Browse files
author
Rusty Rain
authored
Merge pull request #1 from vitdevelop/main
Add tokio-console for data-channels-flow-control
2 parents 8de15cb + 4030173 commit 4aa4f5b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ serde_json = "1.0"
3636
bytes = "1"
3737
lazy_static = "1.4"
3838
rand = "0.8"
39+
console-subscriber = { git = "https://github.com/tokio-rs/console", branch = "main" }
3940

4041
[profile.dev]
4142
opt-level = 0

examples/data-channels-flow-control/data-channels-flow-control.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,16 @@ async fn create_offerer() -> Result<Arc<RTCPeerConnection>> {
9393
tokio::spawn(async move {
9494
let buf = Bytes::from_static(&[0u8; 1024]);
9595
while dc2.send(&buf).await.is_ok() {
96+
tokio::time::sleep(Duration::from_millis(10)).await;
9697
let buffered_amount = dc2.buffered_amount().await;
9798
if buffered_amount + buf.len() > MAX_BUFFERED_AMOUNT {
9899
// Wait until the bufferedAmount becomes lower than the threshold
99-
println!(
100-
"buffered_amount {} + sent {} > MAX_BUFFERED_AMOUNT {}",
101-
buffered_amount,
102-
buf.len(),
103-
MAX_BUFFERED_AMOUNT
104-
);
100+
// println!(
101+
// "buffered_amount {} + sent {} > MAX_BUFFERED_AMOUNT {}",
102+
// buffered_amount,
103+
// buf.len(),
104+
// MAX_BUFFERED_AMOUNT
105+
// );
105106
let _ = send_more_ch_rx.recv().await;
106107
}
107108
}
@@ -206,6 +207,8 @@ async fn create_answerer() -> Result<Arc<RTCPeerConnection>> {
206207

207208
#[tokio::main]
208209
async fn main() -> Result<()> {
210+
console_subscriber::init();
211+
209212
let mut app = App::new("data-channels-flow-control")
210213
.version("0.1.0")
211214
.author("Rain Liu <yliu@webrtc.rs>")

0 commit comments

Comments
 (0)