@@ -92,6 +92,7 @@ use std::pin::Pin;
92
92
use std:: task:: { self , Poll } ;
93
93
94
94
use bytes:: Bytes ;
95
+ use futures:: channel:: mpsc;
95
96
#[ cfg( feature = "websocket" ) ]
96
97
use futures:: StreamExt ;
97
98
use futures:: { future, FutureExt , TryFutureExt } ;
@@ -102,9 +103,7 @@ use http::{
102
103
use serde:: Serialize ;
103
104
use serde_json;
104
105
#[ cfg( feature = "websocket" ) ]
105
- use tokio:: sync:: { mpsc, oneshot} ;
106
- #[ cfg( feature = "websocket" ) ]
107
- use tokio_stream:: wrappers:: UnboundedReceiverStream ;
106
+ use tokio:: sync:: oneshot;
108
107
109
108
use crate :: filter:: Filter ;
110
109
use crate :: reject:: IsReject ;
@@ -484,9 +483,8 @@ impl WsBuilder {
484
483
F :: Error : IsReject + Send ,
485
484
{
486
485
let ( upgraded_tx, upgraded_rx) = oneshot:: channel ( ) ;
487
- let ( wr_tx, wr_rx) = mpsc:: unbounded_channel ( ) ;
488
- let wr_rx = UnboundedReceiverStream :: new ( wr_rx) ;
489
- let ( rd_tx, rd_rx) = mpsc:: unbounded_channel ( ) ;
486
+ let ( wr_tx, wr_rx) = mpsc:: unbounded ( ) ;
487
+ let ( rd_tx, rd_rx) = mpsc:: unbounded ( ) ;
490
488
491
489
tokio:: spawn ( async move {
492
490
use tokio_tungstenite:: tungstenite:: protocol;
@@ -546,7 +544,7 @@ impl WsBuilder {
546
544
Ok ( m) => future:: ready ( !m. is_close ( ) ) ,
547
545
} )
548
546
. for_each ( move |item| {
549
- rd_tx. send ( item) . expect ( "ws receive error" ) ;
547
+ rd_tx. unbounded_send ( item) . expect ( "ws receive error" ) ;
550
548
future:: ready ( ( ) )
551
549
} ) ;
552
550
@@ -573,13 +571,13 @@ impl WsClient {
573
571
574
572
/// Send a websocket message to the server.
575
573
pub async fn send ( & mut self , msg : crate :: ws:: Message ) {
576
- self . tx . send ( msg) . unwrap ( ) ;
574
+ self . tx . unbounded_send ( msg) . unwrap ( ) ;
577
575
}
578
576
579
577
/// Receive a websocket message from the server.
580
578
pub async fn recv ( & mut self ) -> Result < crate :: filters:: ws:: Message , WsError > {
581
579
self . rx
582
- . recv ( )
580
+ . next ( )
583
581
. await
584
582
. map ( |result| result. map_err ( WsError :: new) )
585
583
. unwrap_or_else ( || {
@@ -591,7 +589,7 @@ impl WsClient {
591
589
/// Assert the server has closed the connection.
592
590
pub async fn recv_closed ( & mut self ) -> Result < ( ) , WsError > {
593
591
self . rx
594
- . recv ( )
592
+ . next ( )
595
593
. await
596
594
. map ( |result| match result {
597
595
Ok ( msg) => Err ( WsError :: new ( format ! ( "received message: {:?}" , msg) ) ) ,
0 commit comments