File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -14,19 +14,23 @@ async fn main() -> Result<(), Error> {
1414
1515 let ( mut tx, mut rx) = websocket. split ( ) ;
1616
17- tokio:: task:: spawn_local ( async move {
18- for i in 1 ..11 {
19- tx. send ( Message :: Text ( format ! ( "Hello, World! #{i}" ) ) )
20- . await
21- . unwrap ( ) ;
22- }
23- } ) ;
24-
25- while let Some ( message) = rx. try_next ( ) . await ? {
26- if let Message :: Text ( text) = message {
27- println ! ( "received: {text}" ) ;
28- }
29- }
17+ futures_util:: future:: join (
18+ async move {
19+ for i in 1 ..11 {
20+ tx. send ( Message :: Text ( format ! ( "Hello, World! #{i}" ) ) )
21+ . await
22+ . unwrap ( ) ;
23+ }
24+ } ,
25+ async move {
26+ while let Some ( message) = rx. try_next ( ) . await . unwrap ( ) {
27+ if let Message :: Text ( text) = message {
28+ println ! ( "received: {text}" ) ;
29+ }
30+ }
31+ } ,
32+ )
33+ . await ;
3034
3135 Ok ( ( ) )
3236}
You can’t perform that action at this time.
0 commit comments