File tree Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -15,19 +15,22 @@ pub fn connect(addr: &SocketAddr) -> TcpStream {
1515}
1616
1717pub async fn process ( socket : TcpStream , mut inputs : Rx , outputs : Tx ) {
18- let mut stream = Framed :: new ( socket, RFrameCodec ) ;
19- loop {
20- match stream. next ( ) . await {
21- Some ( it) => outputs. send ( it. unwrap ( ) ) . unwrap ( ) ,
22- None => {
23- drop ( outputs) ;
24- break ;
18+ let ( mut writer, mut reader) = Framed :: new ( socket, RFrameCodec ) . split ( ) ;
19+ tokio:: spawn ( async move {
20+ loop {
21+ match reader. next ( ) . await {
22+ Some ( it) => outputs. send ( it. unwrap ( ) ) . unwrap ( ) ,
23+ None => {
24+ drop ( outputs) ;
25+ break ;
26+ }
2527 }
2628 }
27- // TODO: How to split R/W ???
28- // match inputs.recv().await {
29- // Some(v) => stream.send(v).await.unwrap(),
30- // None => (),
31- // }
29+ } ) ;
30+ loop {
31+ match inputs. recv ( ) . await {
32+ Some ( it) => writer. send ( it) . await . unwrap ( ) ,
33+ None => break ,
34+ }
3235 }
3336}
You can’t perform that action at this time.
0 commit comments