Added audio sender test and disconnect reasons

This commit is contained in:
Manevolent
2018-12-21 11:02:08 -05:00
parent 24da34d23d
commit 9d602a8f98
10 changed files with 994 additions and 22 deletions
@@ -1088,16 +1088,34 @@ public class LocalTeamspeakClientSocket
throws
IOException, TimeoutException,
ExecutionException, InterruptedException {
disconnect(null);
}
public void disconnect(String reason)
throws
IOException, TimeoutException,
ExecutionException, InterruptedException {
try {
switch (getState()) {
case CONNECTING:
case RETRIEVING_DATA:
waitForState(ClientConnectionState.CONNECTED, 10000L);
case CONNECTED:
writePacket(new PacketBody2Command(
ProtocolRole.CLIENT,
new SingleCommand("clientdisconnect", ProtocolRole.CLIENT))
);
if (reason == null) {
writePacket(new PacketBody2Command(
ProtocolRole.CLIENT,
new SingleCommand("clientdisconnect", ProtocolRole.CLIENT))
);
} else {
writePacket(new PacketBody2Command(
ProtocolRole.CLIENT,
new SingleCommand(
"clientdisconnect", ProtocolRole.CLIENT,
new CommandSingleParameter("reasonid", "8"),
new CommandSingleParameter("reasonmsg", reason)
))
);
}
waitForState(ClientConnectionState.DISCONNECTED, 30000L);
@@ -10,6 +10,7 @@ import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
import com.github.manevolent.ts3j.protocol.packet.PacketBody0Voice;
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
import com.github.manevolent.ts3j.util.Ts3Debugging;
import com.sun.security.ntlm.Server;
import java.math.BigInteger;
import java.net.InetSocketAddress;
@@ -20,34 +21,29 @@ import static org.junit.Assert.assertEquals;
public class ServerConnectionTest {
public static void main(String[] args) throws Exception {
Ts3Debugging.setEnabled(true);
LocalTeamspeakClientSocket client = new LocalTeamspeakClientSocket();
Ts3Debugging.setEnabled(false);
LocalIdentity identity = LocalIdentity.generateNew(10);
client.setIdentity(identity);
client.setNickname("ts3j issue 2");
client.setNickname(ServerConnectionTest.class.getSimpleName());
client.setHWID("TestTestTest");
client.setVoiceHandler(packet ->
System.out.println(packet.getServerFlag0())
);
try {
client.connect(
"teamlixo.net",
10000L
);
while (true) {
try {
client.connect(
"teamlixo.net",
10000L
);
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
} catch (Exception ex) {
ex.printStackTrace();
}
Thread.sleep(30000);
client.disconnect("BYE");
} catch (Exception ex) {
ex.printStackTrace();
}
Thread.sleep(3000L);
}
}