Add close method to websocket client

This commit is contained in:
mbohlool 2017-02-27 12:30:15 -08:00
parent c85b8f5733
commit 94861c777e
3 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,6 @@
# v1.0.1
- Bugfix: blocking exec call should remove channel metadata #140
- Add close method to websocket api of interactive exec #145
# v1.0.0b3
- Bugfix: Missing websocket-client dependency #131

View File

@ -92,3 +92,4 @@ print("Server date command returns: %s" % sdate)
resp.write_stdin("whoami\n")
user = resp.readline_stdout(timeout=3)
print("Server user is: %s" % user)
resp.close()

View File

@ -191,6 +191,14 @@ class WSClient:
while self.is_open():
self.update(timeout=None)
def close(self, **kwargs):
"""
close websocket connection.
"""
self._connected = False
if self.sock:
self.sock.close(**kwargs)
WSResponse = collections.namedtuple('WSResponse', ['data'])