| Constructor and Description |
|---|
TS3Config() |
| Modifier and Type | Method and Description |
|---|---|
TS3Config |
setCommandTimeout(int commandTimeout)
Sets how long the query should wait for any response to a command before disconnecting.
|
TS3Config |
setConnectionHandler(ConnectionHandler connectionHandler)
Sets the
ConnectionHandler that defines the query's behaviour
when connecting or disconnecting. |
TS3Config |
setEnableCommunicationsLogging(boolean enable)
Setting this value to
true will log the communication between the
query client and the TS3 server at the DEBUG level. |
TS3Config |
setFloodRate(TS3Query.FloodRate rate)
Sets the delay between sending commands.
|
TS3Config |
setHost(String host)
Sets the hostname or IP address of the TeamSpeak3 server to connect to.
|
TS3Config |
setLoginCredentials(String username,
String password)
Authenticates the query with the TeamSpeak3 server using the given login credentials
immediately after connecting.
|
TS3Config |
setProtocol(TS3Query.Protocol protocol)
Defines the protocol used to connect to the TeamSpeak3 server.
|
TS3Config |
setQueryPort(int queryPort)
Sets the query port to use when connecting to the TeamSpeak3 server.
|
TS3Config |
setReconnectStrategy(ReconnectStrategy reconnectStrategy)
Sets what strategy the query uses to reconnect after having been disconnected.
|
public TS3Config()
public TS3Config setHost(String host)
Note that the query port is not part of the hostname -
use setQueryPort(int) for that purpose.
If the application is running on the same machine as the TS3 server, you can use
null as the hostname. You can also use any other loopback address,
such as localhost or 127.0.0.1.
host - a valid hostname or IP address of a TeamSpeak3 server, or nullpublic TS3Config setQueryPort(int queryPort)
Note that the query uses a different port to connect to a server than the regular TeamSpeak3 clients. Regular clients use "voice ports", the query uses the "query port".
If you don't set the query port by calling this method, the query will use the default query port:
10011 when connecting using TS3Query.Protocol.RAW10022 when connecting using TS3Query.Protocol.SSHqueryPort - the query port to use, must be between 1 and 65535IllegalArgumentException - if the port is out of rangepublic TS3Config setProtocol(TS3Query.Protocol protocol)
TS3Query.Protocol.RAW is used.protocol - the connection protocol to useIllegalArgumentException - if protocol is nullProtocolpublic TS3Config setLoginCredentials(String username, String password)
Setting the login credentials is mandatory when using the TS3Query.Protocol.SSH protocol.
A server query login can be generated by heading over to the TeamSpeak3 Client, Tools, ServerQuery Login. Note that the server query will have the same permissions as the client who generated the credentials.
username - the username used to authenticate the querypassword - the password corresponding to usernamepublic TS3Config setFloodRate(TS3Query.FloodRate rate)
If the query's hostname / IP has not been added to the server's query_ip_whitelist.txt,
you need to use TS3Query.FloodRate.DEFAULT to prevent the query from being flood-banned.
Calling TS3Query.FloodRate.custom(int) allows you to use a custom command delay if neither
TS3Query.FloodRate.UNLIMITED nor TS3Query.FloodRate.DEFAULT fit your needs.
rate - a TS3Query.FloodRate object that defines the delay between commandsIllegalArgumentException - if rate is nullFloodRatepublic TS3Config setEnableCommunicationsLogging(boolean enable)
true will log the communication between the
query client and the TS3 server at the DEBUG level.
By default, this is turned off to prevent leaking IPs, tokens, passwords, etc. into the console and / or log files.
enable - whether to log query commandspublic TS3Config setCommandTimeout(int commandTimeout)
If the query doesn't receive any data from the TeamSpeak server after
having waited for at least commandTimeout milliseconds, the connection
is considered to be interrupted, and the query will try to reconnect according to
its reconnect strategy.
By default, this timeout is 4000 milliseconds.
commandTimeout - the minimum amount of time to wait for any response, in millisecondsIllegalArgumentException - if the timeout value is less than or equal to 0public TS3Config setReconnectStrategy(ReconnectStrategy reconnectStrategy)
The different reconnect strategies let you control whether and after which delay the
query will try to reconnect. By default, ReconnectStrategy.disconnect() is used,
which doesn't try to reconnect and simply stops the query.
Note that when using a reconnect strategy, you probably also want to set the
ConnectionHandler using setConnectionHandler(ConnectionHandler).
reconnectStrategy - the reconnect strategy used when the query loses connectionThe reconnect strategies,
The connection handlerpublic TS3Config setConnectionHandler(ConnectionHandler connectionHandler)
ConnectionHandler that defines the query's behaviour
when connecting or disconnecting.
The following sample code illustrates how a reconnect strategy and connection handler can be used to print a message to the console every time the query connects or disconnects:
config.setReconnectStrategy(ReconnectStrategy.exponentialBackoff());
config.setConnectionHandler(new ConnectionHandler() {
@Override
public void onConnect(TS3Api api) {
System.out.println("Successfully connected!");
}
@Override
public void onDisconnect(TS3Query query) {
System.out.println("The query was disconnected!");
}
});
connectionHandler - the ConnectionHandler objectsetReconnectStrategy(ReconnectStrategy)Released under the MIT license.