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] 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 47dac77..44a56d6 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 2edfdd9..3059e5f 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 59e41cd..bcf29ae 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