From e0a1fdfa3829a7eb2221530002c6b8ec2f5b18be Mon Sep 17 00:00:00 2001
From: Karishma Chadha <kchadha@media.mit.edu>
Date: Mon, 29 Oct 2018 01:02:09 -0400
Subject: [PATCH] Add API to close connection and clean up cloud provider.

---
 src/lib/cloud-provider.js | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/lib/cloud-provider.js b/src/lib/cloud-provider.js
index b2c500287..0b7c380b1 100644
--- a/src/lib/cloud-provider.js
+++ b/src/lib/cloud-provider.js
@@ -99,6 +99,26 @@ class CloudProvider {
         this.writeToServer('set', name, value);
     }
 
+    /**
+     * Closes the connection to the web socket and clears the cloud
+     * provider of references related to the cloud data project.
+     */
+    requestCloseConnection () {
+        this.connection.close();
+        this.clear();
+    }
+
+    /**
+     * Clear this provider of references related to the project
+     * and current state.
+     */
+    clear () {
+        this.connection = null;
+        this.vm = null;
+        this.username = null;
+        this.projectId = null;
+    }
+
 }
 
 export default CloudProvider;
-- 
GitLab