mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-11 01:26:22 +01:00
Teamspeak 3 Updates (#741)
* Correct duplicate error and success messages to user * Read out all buffer bytes before sending command * Convert ts3 manager to use a single connection Each instance of the class will now use a single connection and should be cleanly disconnected when finished. Compatible with `with` clauses and will automatically disconnect from the TS3 server when it exits the `with` block. * Update TS3 manager consumers to use new style * Update unit tests to use new style manager
This commit is contained in:
@@ -50,13 +50,24 @@ class TS3Proto:
|
||||
return True
|
||||
|
||||
def disconnect(self):
|
||||
self.send_command("quit")
|
||||
self._conn.close()
|
||||
self._connected = False
|
||||
self._log.info('Disconnected')
|
||||
if self._connected:
|
||||
try:
|
||||
self.send("quit")
|
||||
self._conn.close()
|
||||
except:
|
||||
self._log.exception('Error while disconnecting')
|
||||
self._connected = False
|
||||
self._log.info('Disconnected')
|
||||
else:
|
||||
self._log.info("Not connected")
|
||||
|
||||
def send_command(self, command, keys=None, opts=None):
|
||||
cmd = self.construct_command(command, keys=keys, opts=opts)
|
||||
|
||||
# Clear read buffer of any stray bytes
|
||||
self._conn.read_very_eager()
|
||||
|
||||
# Send command
|
||||
self.send('%s\n' % cmd)
|
||||
|
||||
data = []
|
||||
|
||||
Reference in New Issue
Block a user