pymumble
pymumble copied to clipboard
Function to disconnect from current server without ending the program
Is there a function somewhere to manually disconnect from the server without exiting the program?
Also apologies for the issue on the mumbleradioplayer git, accidentally asked there first. Looking at the code for !kill on that project it seems that the command only exits completely when I just want to kill the thread
no problem for the issue.
The simple answer is not. The main loop don't have reset/disconnect/stop feature.
You can force the state of self.connected
and the loop will start the connection part again.
It's should not hard to implement a real function for that, but I don't see any use case.
Az
Thanks for the quick answer. I'll just hack something together for my very stupid use case.
@enthrow Did you implement the disconnection functionality? If so, would you mind sharing the code with us?
This works, but there's probably a better way to do it
diff --git a/pymumble_py3/mumble.py b/pymumble_py3/mumble.py
index 8b45e6f..6df3485 100644
--- a/pymumble_py3/mumble.py
+++ b/pymumble_py3/mumble.py
@@ -163,6 +163,12 @@ class Mumble(threading.Thread):
self.connected = PYMUMBLE_CONN_STATE_AUTHENTICATING
return self.connected
+ def close(self):
+ if self.connected == PYMUMBLE_CONN_STATE_CONNECTED:
+ self.reconnect = False
+ self.connected = PYMUMBLE_CONN_STATE_NOT_CONNECTED
+ self.control_socket.close()
+
def loop(self):
"""
Main loop