-
Notifications
You must be signed in to change notification settings - Fork 968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated websocket example to improve clarity and to be more distinct from chat example #1637
Conversation
… version of Chat. Added more descriptive comments and examples of various data types that can be shipped over websockets.
…l as proper documentation for Ping/Pong mechanism.
Thanks! I skimmed the changes and they generally look good. Will do a more thorough review later. However we cannot merge Python code. I don't know Python so don't wanna take on maintenance of that. Can you write the client in Rust instead? |
Well websocket client in Rust might be a bit more "fun" than I originally anticipated, but I can give it a try. Stay tuned. |
All right, now there is a proper Rust client, which is properly illustrating the concurrency features of axum websockets. |
All the "trivial suggestions" from review. More substantial refinement to follow. Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
…own code to match review requests.
Ok the fat trimming is done, I hope I have not missed anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Almost there. Just a couple of minor nitpicks here and there.
Applied all suggestions as is, pending testing. Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
…and runs correctly.
Thanks for the tips! I've re-tested everything (there was a missing import and one unneeded import) and the last commit should contain a fully functional example with all your suggestions incorporated. |
Bump =) |
No need for bumps. We'll get to this when we get to it. I'm currently on Christmas holiday playing video games. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
You are welcome! I quite like your standards of quality, gives me confidence using Axum in production. |
I'm sure many people are going to benefit from this example, including the command-line client. Big thank you to both! I was wondering how to run the example and then I saw the comments in main.rs (of course). Small nit, at least for me to get them running: diff --git a/examples/websockets/src/main.rs b/examples/websockets/src/main.rs
index 26a31a2..6d598b1 100644
--- a/examples/websockets/src/main.rs
+++ b/examples/websockets/src/main.rs
@@ -3,13 +3,13 @@
//! Run the server with
//!
//! ```not_rust
-//! cargo run -p example-websockets
+//! cargo run -p example-websockets --bin example-websockets
//! firefox http://localhost:3000
//! ```
//!
//! Alternatively you can run the rust client with
//! ```not_rust
-//! cargo run -p example-client
+//! cargo run -p example-websockets --bin example-client
//! ``` |
@FrankReh good catch! Wanna submit a PR? |
Motivation
The web sockets example was not looking nice, it was not user-friendly at all (took a while to figure out what it was even supposed to be able to do). Furthermore, it was not actually showcasing anything about web sockets that the chat example did not already demonstrate better. Either it had to go, or it had to be made more distinct, so I took the time to make it more "involved".
Solution