Skip to content

Commit

Permalink
Attempt to reopen failed connections
Browse files Browse the repository at this point in the history
  • Loading branch information
olijeffers0n committed Jan 1, 2022
1 parent 646cc21 commit 43f6783
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rustplus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

__name__ = "rustplus"
__author__ = "olijefferson"
__version__ = "5.1.3"
__version__ = "5.1.4"
__support__ = "Discord: https://discord.gg/nQqJe8qvP8"
11 changes: 8 additions & 3 deletions rustplus/api/remote/rust_remote_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self, ip, port, command_options, ratelimit_limit, ratelimit_refill)
self.ratelimit_limit = ratelimit_limit
self.ratelimit_refill = ratelimit_refill
self.ratelimiter = RateLimiter(ratelimit_limit, ratelimit_limit, 1, ratelimit_refill)
self.open = False

if command_options is None:
self.use_commands = False
Expand All @@ -29,16 +30,20 @@ def connect(self) -> None:
self.ws = RustWsClient(ip=self.ip, port=self.port, remote=self, protocols=['http-only', 'chat'])
self.ws.daemon = True
self.ws.connect()
self.open = True

def close(self) -> None:

if self.ws:
if self.ws is not None:
self.ws.close()
self.ws = None
self.open = False

def sock(self) -> RustWsClient:

if self.ws is None:
raise ClientNotConnectedError("No Current Websocket Connection")

if not self.open:
raise ClientNotConnectedError("No Current Websocket Connection")
else:
self.connect()
return self.ws

0 comments on commit 43f6783

Please sign in to comment.