Просмотр исходного кода

add is_running() function to gatewayclient to check if the connection is
started

ghassmo 5 лет назад
Родитель
Сommit
96f91b2749
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      src/service/gateway.rs

+ 7 - 1
src/service/gateway.rs

@@ -181,6 +181,7 @@ pub struct GatewayClient {
     slabstore: Arc<SlabStore>,
     gateway_slabs_sub_s: async_channel::Sender<Slab>,
     gateway_slabs_sub_rv: GatewaySlabsSubscriber,
+    is_running: bool,
 }
 
 impl GatewayClient {
@@ -196,13 +197,14 @@ impl GatewayClient {
             slabstore,
             gateway_slabs_sub_s,
             gateway_slabs_sub_rv,
+            is_running: false,
         })
     }
 
     pub async fn start(&mut self) -> Result<()> {
         self.protocol.start().await?;
         self.sync().await?;
-
+        self.is_running = true;
         Ok(())
     }
 
@@ -311,6 +313,10 @@ impl GatewayClient {
             slabstore.put(slab)?;
         }
     }
+
+    pub fn is_running(&self) -> bool {
+        self.is_running
+    }
 }
 
 fn handle_error(status_code: u32) {