File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ async fn main() -> anyhow::Result<()> {
4141    while  let  Some ( msg)  = stream. next ( ) . await  { 
4242        println ! ( "Received update: {:?}" ,  msg?) ; 
4343        count += 1 ; 
44-         if  count >= 50  { 
44+         if  count >= 10  { 
4545            break ; 
4646        } 
4747    } 
@@ -51,5 +51,6 @@ async fn main() -> anyhow::Result<()> {
5151    println ! ( "Unsubscribed from {:?}" ,  subscription_id) ; 
5252
5353    tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 500 ) ) . await ; 
54+     client. close ( ) . await ?; 
5455    Ok ( ( ) ) 
5556} 
Original file line number Diff line number Diff line change @@ -179,4 +179,15 @@ impl LazerClient {
179179            anyhow:: bail!( "WebSocket connection not started" ) 
180180        } 
181181    } 
182+ 
183+     /// Closes the WebSocket connection 
184+      pub  async  fn  close ( & mut  self )  -> Result < ( ) >  { 
185+         if  let  Some ( sender)  = & mut  self . ws_sender  { 
186+             sender. send ( Message :: Close ( None ) ) . await ?; 
187+             self . ws_sender  = None ; 
188+             Ok ( ( ) ) 
189+         }  else  { 
190+             anyhow:: bail!( "WebSocket connection not started" ) 
191+         } 
192+     } 
182193} 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments