Ver código fonte

Allow the client to logout and reconnect

Tankernn 7 anos atrás
pai
commit
a1bd9ebcd1
1 arquivos alterados com 8 adições e 2 exclusões
  1. 8 2
      cbc/client.py

+ 8 - 2
cbc/client.py

@@ -103,7 +103,10 @@ class MyPrompt(Cmd):
         else:
             print("Not enough units.")
 
-
+    def do_logout(self, args):
+        """Log out."""
+        self.ws.close()
+        return True
 
     def do_resources(self, args):
         """List available resources."""
@@ -182,7 +185,10 @@ def on_error(ws, error):
     print(error)
 
 def on_close(ws):
-    print("### closed ###")
+    global prompt
+    print("### Connection to server closed ###")
+    prompt = None
+    connect()
 
 def on_open(username, password, register=False):
     def run(ws):