Skip to content

Commit

Permalink
Make ping payload random
Browse files Browse the repository at this point in the history
  • Loading branch information
nathiss committed Jul 31, 2023
1 parent ae1f969 commit bfe615c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"cSpell.words": [
"Clippy",
"Deque",
"fastrand",
"humantime",
"katyo",
"thiserror",
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ futures = "0.3.28"
humantime-serde = "1.1.1"
cancellable = "0.3.0"
async-trait = "0.1.72"
fastrand = "2.0.0"

[dev-dependencies]
anyhow = "1.0.71"
Expand Down
7 changes: 2 additions & 5 deletions src/connection/connection_handle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
iter::repeat_with,
sync::{
atomic::{AtomicBool, Ordering},
Arc, Weak,
Expand Down Expand Up @@ -115,8 +116,7 @@ where
break;
};

// TODO: make it random?
let payload = vec![42u8];
let payload: Vec<_> = repeat_with(|| fastrand::u8(0..255)).take(10).collect();

if let Err(e) = sink
.lock_owned()
Expand Down Expand Up @@ -150,9 +150,6 @@ where
if let Err(e) = futures::executor::block_on(async move {
let mut sink = sink.lock_owned().await;

// XXX: To be confirmed, but probably we do not need to send a close frame manually -- WebSocket library
// should take care of that.
// sink.feed(Message::Close(None)).await?;
sink.flush().await?;
sink.close().await?;

Expand Down

0 comments on commit bfe615c

Please sign in to comment.