From 6eaf0646163286cfc51941152587461ea9dd3518 Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Sun, 21 Jul 2024 18:45:26 -0400 Subject: [PATCH 1/4] chore: change to version from workspace --- websockets/echo/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websockets/echo/Cargo.toml b/websockets/echo/Cargo.toml index 980ce368..e6491456 100644 --- a/websockets/echo/Cargo.toml +++ b/websockets/echo/Cargo.toml @@ -22,4 +22,4 @@ env_logger.workspace = true futures-util = { workspace = true, features = ["sink"] } log.workspace = true tokio = { workspace = true, features = ["full"] } -tokio-stream = "0.1.8" +tokio-stream.workspace = true From f75719d1d0835ac85d3cbebef7440db1bda2a519 Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Sun, 21 Jul 2024 20:25:41 -0400 Subject: [PATCH 2/4] Move client file from old example --- websockets/{echo => echo-actorless}/src/client.rs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename websockets/{echo => echo-actorless}/src/client.rs (100%) diff --git a/websockets/echo/src/client.rs b/websockets/echo-actorless/src/client.rs similarity index 100% rename from websockets/echo/src/client.rs rename to websockets/echo-actorless/src/client.rs From 27be660389a9e59c4827a9e09c5fc1ca5c152b03 Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Sun, 21 Jul 2024 20:26:38 -0400 Subject: [PATCH 3/4] Add soft link to moved file --- websockets/echo/src/client.rs | 1 + 1 file changed, 1 insertion(+) create mode 120000 websockets/echo/src/client.rs diff --git a/websockets/echo/src/client.rs b/websockets/echo/src/client.rs new file mode 120000 index 00000000..eaf20399 --- /dev/null +++ b/websockets/echo/src/client.rs @@ -0,0 +1 @@ +../../echo-actorless/src/client.rs \ No newline at end of file From 21b6cd1d36898d6b66ad1419702c5c3053a76e2f Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Sun, 21 Jul 2024 20:26:59 -0400 Subject: [PATCH 4/4] Add rust client to echo-actorless - Make it easier for users to find rust code they can use for the client - Remove the need to install websocat to get cli --- Cargo.lock | 2 ++ websockets/echo-actorless/Cargo.toml | 12 +++++++++++- websockets/echo-actorless/README.md | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47dac77e..44a56d6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8932,10 +8932,12 @@ dependencies = [ "actix-files", "actix-web", "actix-ws", + "awc", "env_logger", "futures-util", "log", "tokio", + "tokio-stream", ] [[package]] diff --git a/websockets/echo-actorless/Cargo.toml b/websockets/echo-actorless/Cargo.toml index 2edfdd92..3059e5f2 100644 --- a/websockets/echo-actorless/Cargo.toml +++ b/websockets/echo-actorless/Cargo.toml @@ -3,11 +3,21 @@ name = "websockets-echo-actorless-example" version = "1.0.0" edition = "2021" +[[bin]] +name = "websocket-server" +path = "src/main.rs" + +[[bin]] +name = "websocket-client" +path = "src/client.rs" + [dependencies] actix-files.workspace = true actix-web.workspace = true actix-ws.workspace = true +awc.workspace = true env_logger.workspace = true -futures-util.workspace = true +futures-util = { workspace = true, features = ["sink"] } log.workspace = true tokio = { workspace = true, features = ["rt", "time", "macros"] } +tokio-stream.workspace = true diff --git a/websockets/echo-actorless/README.md b/websockets/echo-actorless/README.md index 59e41cda..bcf29ae5 100644 --- a/websockets/echo-actorless/README.md +++ b/websockets/echo-actorless/README.md @@ -8,7 +8,7 @@ Simple echo websocket server using [`actix-ws`]. ```sh cd websockets/echo-actorless -cargo run +cargo run --bin websocket-server # starting HTTP server at http://localhost:8080 ``` @@ -16,6 +16,13 @@ cargo run Go to in a browser. +### rust client + +```sh +cd websockets/echo-actorless +cargo run --bin websocket-client +``` + ### CLI Client ```sh