Skip to content

Commit

Permalink
change example to use tokio::spawn again
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraef committed Jul 9, 2024
1 parent 2b0a64f commit 3e75043
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ web-sys = { version = "0.3", features = ["WebSocket", "CloseEvent", "ErrorEvent"
wasm-bindgen-futures = "0.4"

[dev-dependencies]
tokio = { version = "1", features = ["macros", "rt"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
reqwest = { version = "0.12", features = ["default-tls"] }
serde = { version = "1.0", features = ["derive"] }

Expand Down
4 changes: 2 additions & 2 deletions examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use futures_util::{SinkExt, StreamExt, TryStreamExt};
use reqwest::Client;
use reqwest_websocket::{Error, Message, RequestBuilderExt};

#[tokio::main(flavor = "current_thread")]
#[tokio::main]
async fn main() -> Result<(), Error> {
let websocket = Client::default()
.get("wss://echo.websocket.org/")
Expand All @@ -14,7 +14,7 @@ async fn main() -> Result<(), Error> {

let (mut tx, mut rx) = websocket.split();

tokio::task::spawn_local(async move {
tokio::spawn(async move {
for i in 1..11 {
tx.send(Message::Text(format!("Hello, World! #{i}")))
.await
Expand Down

0 comments on commit 3e75043

Please sign in to comment.