diff --git a/src/main/java/com/github/manevolent/ts3j/command/MultiCommand.java b/src/main/java/com/github/manevolent/ts3j/command/MultiCommand.java index c15554b..1d4d01a 100644 --- a/src/main/java/com/github/manevolent/ts3j/command/MultiCommand.java +++ b/src/main/java/com/github/manevolent/ts3j/command/MultiCommand.java @@ -129,6 +129,10 @@ public class MultiCommand implements Command { singleCommands.add(command); } + // Make sure is empty if needed + if (singleCommands.size() <= 0) + singleCommands.add(new SingleCommand(label, role)); + return new MultiCommand(label, role, singleCommands); } } diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java index b8179b3..7cd417d 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java @@ -60,12 +60,16 @@ public class LocalTeamspeakClientSocket private int acceptingReturnCode = 0; private int lastReturnCode = 0; + + private Integer serverId = null; + private Map awaitingCommands = new ConcurrentHashMap<>(); public LocalTeamspeakClientSocket() { super(); namedProcessors.put("initserver", new InitServerHandler()); + namedProcessors.put("channellist", new CommandProcessor() { @Override public void process(AbstractTeamspeakClientSocket client, SingleCommand singleCommand) @@ -74,6 +78,7 @@ public class LocalTeamspeakClientSocket for (TS3Listener listener : listeners) listener.onChannelList(channelListEvent); } }); + namedProcessors.put("channellistfinished", new ChannelListFinishedHandler()); } @@ -446,6 +451,8 @@ public class LocalTeamspeakClientSocket throws CommandProcessException { try { setClientId(Integer.parseInt(singleCommand.get("aclid").getValue())); + setNickname(singleCommand.get("acn").getValue()); + serverId = Integer.parseInt(singleCommand.get("virtualserver_id").getValue()); } catch (Exception e) { throw new CommandProcessException(e); } @@ -619,7 +626,8 @@ public class LocalTeamspeakClientSocket throws IOException, TimeoutException, ExecutionException, InterruptedException { Command command = new SingleCommand("sendtextmessage", ProtocolRole.CLIENT); - command.add(new CommandSingleParameter("targetmode", Integer.toString(1))); + command.add(new CommandSingleParameter("targetmode", Integer.toString(3))); + command.add(new CommandSingleParameter("target", Integer.toString(serverId))); command.add(new CommandSingleParameter("msg", message)); executeCommand(command).complete(); @@ -648,7 +656,7 @@ public class LocalTeamspeakClientSocket throws IOException, TimeoutException, ExecutionException, InterruptedException { Command command = new SingleCommand("sendtextmessage", ProtocolRole.CLIENT); - command.add(new CommandSingleParameter("targetmode", Integer.toString(3))); + command.add(new CommandSingleParameter("targetmode", Integer.toString(1))); command.add(new CommandSingleParameter("target", Integer.toString(clientId))); command.add(new CommandSingleParameter("msg", message)); diff --git a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java index 85d4e00..992d6df 100644 --- a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java +++ b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java @@ -40,6 +40,8 @@ public class ServerConnectionTest { assertEquals(client.getState(), ClientConnectionState.CONNECTED); + client.sendServerMessage("Heyyyy"); + while (true) { Thread.sleep(1000L);