Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to disconnect from current server without ending the program #38

Open
enthrow opened this issue May 6, 2019 · 4 comments
Open

Comments

@enthrow
Copy link

enthrow commented May 6, 2019

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

@azlux
Copy link
Owner

azlux commented May 6, 2019

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

@enthrow
Copy link
Author

enthrow commented May 6, 2019

Thanks for the quick answer. I'll just hack something together for my very stupid use case.

@enthrow enthrow closed this as completed May 6, 2019
@ArniDagur
Copy link

@enthrow Did you implement the disconnection functionality? If so, would you mind sharing the code with us?

@ArniDagur
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants