Channel list event is back, adding chat to client commands.
This commit is contained in:
@@ -0,0 +1,47 @@
|
|||||||
|
package com.github.manevolent.ts3j.event;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* TeamSpeak 3 Java API
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2014 Bert De Geyter
|
||||||
|
* %%
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.github.manevolent.ts3j.api.ChannelProperty;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ChannelListEvent extends BaseEvent {
|
||||||
|
|
||||||
|
public ChannelListEvent(Map<String, String> map) {
|
||||||
|
super(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChannelId() {
|
||||||
|
return getInt(ChannelProperty.CID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fire(TS3Listener listener) {
|
||||||
|
listener.onChannelList(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,6 +50,8 @@ public interface TS3Listener {
|
|||||||
|
|
||||||
void onChannelPasswordChanged(ChannelPasswordChangedEvent e);
|
void onChannelPasswordChanged(ChannelPasswordChangedEvent e);
|
||||||
|
|
||||||
|
void onChannelList(ChannelListEvent e);
|
||||||
|
|
||||||
void onPrivilegeKeyUsed(PrivilegeKeyUsedEvent e);
|
void onPrivilegeKeyUsed(PrivilegeKeyUsedEvent e);
|
||||||
|
|
||||||
void onChannelGroupList(ChannelGroupListEvent e);
|
void onChannelGroupList(ChannelGroupListEvent e);
|
||||||
@@ -61,5 +63,4 @@ public interface TS3Listener {
|
|||||||
void onClientChannelGroupChanged(ClientChannelGroupChangedEvent e);
|
void onClientChannelGroupChanged(ClientChannelGroupChangedEvent e);
|
||||||
|
|
||||||
void onClientChanged(ClientUpdatedEvent e);
|
void onClientChanged(ClientUpdatedEvent e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ public class Identity {
|
|||||||
|
|
||||||
if (curr > best)
|
if (curr > best)
|
||||||
{
|
{
|
||||||
Ts3Debugging.debug("Improved identity security level: from " + best + " to " + curr);
|
Ts3Debugging.debug("Improved identity security level: from " + best + " to " + curr
|
||||||
|
+ " (" + keyOffset + ")");
|
||||||
keyOffset = lastCheckedKeyOffset;
|
keyOffset = lastCheckedKeyOffset;
|
||||||
best = curr;
|
best = curr;
|
||||||
}
|
}
|
||||||
|
|||||||
+62
-4
@@ -9,6 +9,7 @@ import com.github.manevolent.ts3j.command.*;
|
|||||||
import com.github.manevolent.ts3j.command.parameter.CommandSingleParameter;
|
import com.github.manevolent.ts3j.command.parameter.CommandSingleParameter;
|
||||||
import com.github.manevolent.ts3j.command.response.AbstractCommandResponse;
|
import com.github.manevolent.ts3j.command.response.AbstractCommandResponse;
|
||||||
import com.github.manevolent.ts3j.command.response.CommandResponse;
|
import com.github.manevolent.ts3j.command.response.CommandResponse;
|
||||||
|
import com.github.manevolent.ts3j.event.ChannelListEvent;
|
||||||
import com.github.manevolent.ts3j.event.TS3Event;
|
import com.github.manevolent.ts3j.event.TS3Event;
|
||||||
import com.github.manevolent.ts3j.event.TS3Listener;
|
import com.github.manevolent.ts3j.event.TS3Listener;
|
||||||
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
||||||
@@ -65,7 +66,14 @@ public class LocalTeamspeakClientSocket
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
namedProcessors.put("initserver", new InitServerHandler());
|
namedProcessors.put("initserver", new InitServerHandler());
|
||||||
namedProcessors.put("channellist", new NullRouteHandler());
|
namedProcessors.put("channellist", new CommandProcessor() {
|
||||||
|
@Override
|
||||||
|
public void process(AbstractTeamspeakClientSocket client, SingleCommand singleCommand)
|
||||||
|
throws CommandProcessException {
|
||||||
|
ChannelListEvent channelListEvent = new ChannelListEvent(singleCommand.toMap());
|
||||||
|
for (TS3Listener listener : listeners) listener.onChannelList(channelListEvent);
|
||||||
|
}
|
||||||
|
});
|
||||||
namedProcessors.put("channellistfinished", new ChannelListFinishedHandler());
|
namedProcessors.put("channellistfinished", new ChannelListFinishedHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,7 +421,15 @@ public class LocalTeamspeakClientSocket
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ChannelListFinishedHandler implements CommandProcessor {
|
private class ChannelListFinishedHandler implements CommandProcessor {
|
||||||
|
@Override
|
||||||
|
public void process(AbstractTeamspeakClientSocket client, SingleCommand singleCommand)
|
||||||
|
throws CommandProcessException {
|
||||||
|
try {
|
||||||
|
setState(ClientConnectionState.CONNECTED);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CommandProcessException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NullRouteHandler implements CommandProcessor {
|
private class NullRouteHandler implements CommandProcessor {
|
||||||
@@ -430,8 +446,6 @@ public class LocalTeamspeakClientSocket
|
|||||||
throws CommandProcessException {
|
throws CommandProcessException {
|
||||||
try {
|
try {
|
||||||
setClientId(Integer.parseInt(singleCommand.get("aclid").getValue()));
|
setClientId(Integer.parseInt(singleCommand.get("aclid").getValue()));
|
||||||
|
|
||||||
setState(ClientConnectionState.CONNECTED);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CommandProcessException(e);
|
throw new CommandProcessException(e);
|
||||||
}
|
}
|
||||||
@@ -597,6 +611,50 @@ public class LocalTeamspeakClientSocket
|
|||||||
return executeCommand(command, x -> new Client(x.toMap())).get();
|
return executeCommand(command, x -> new Client(x.toMap())).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a text message a specified target. The type of the target is determined by targetmode while target
|
||||||
|
specifies the ID of the recipient, whether it be a virtual server, a channel or a client.
|
||||||
|
*/
|
||||||
|
public void sendServerMessage(String message)
|
||||||
|
throws IOException, TimeoutException, ExecutionException, InterruptedException {
|
||||||
|
Command command = new SingleCommand("sendtextmessage", ProtocolRole.CLIENT);
|
||||||
|
|
||||||
|
command.add(new CommandSingleParameter("targetmode", Integer.toString(1)));
|
||||||
|
command.add(new CommandSingleParameter("msg", message));
|
||||||
|
|
||||||
|
executeCommand(command).complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a text message a specified target. The type of the target is determined by targetmode while target
|
||||||
|
specifies the ID of the recipient, whether it be a virtual server, a channel or a client.
|
||||||
|
*/
|
||||||
|
public void sendChannelMessage(int channelId, String message)
|
||||||
|
throws IOException, TimeoutException, ExecutionException, InterruptedException {
|
||||||
|
Command command = new SingleCommand("sendtextmessage", ProtocolRole.CLIENT);
|
||||||
|
|
||||||
|
command.add(new CommandSingleParameter("targetmode", Integer.toString(2)));
|
||||||
|
command.add(new CommandSingleParameter("target", Integer.toString(channelId)));
|
||||||
|
command.add(new CommandSingleParameter("msg", message));
|
||||||
|
|
||||||
|
executeCommand(command).complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a text message a specified target. The type of the target is determined by targetmode while target
|
||||||
|
specifies the ID of the recipient, whether it be a virtual server, a channel or a client.
|
||||||
|
*/
|
||||||
|
public void sendPrivateMessage(int clientId, String message)
|
||||||
|
throws IOException, TimeoutException, ExecutionException, InterruptedException {
|
||||||
|
Command command = new SingleCommand("sendtextmessage", ProtocolRole.CLIENT);
|
||||||
|
|
||||||
|
command.add(new CommandSingleParameter("targetmode", Integer.toString(3)));
|
||||||
|
command.add(new CommandSingleParameter("target", Integer.toString(clientId)));
|
||||||
|
command.add(new CommandSingleParameter("msg", message));
|
||||||
|
|
||||||
|
executeCommand(command).complete();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves one or more clients specified with clid to the channel with ID cid. If
|
* Moves one or more clients specified with clid to the channel with ID cid. If
|
||||||
the target channel has a password, it needs to be specified with cpw. If the
|
the target channel has a password, it needs to be specified with cpw. If the
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.github.manevolent.ts3j;
|
||||||
|
|
||||||
|
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
||||||
|
import com.github.manevolent.ts3j.util.Ts3Debugging;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
public class GenerateIdentityTest {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
try {
|
||||||
|
Ts3Debugging.setEnabled(true);
|
||||||
|
|
||||||
|
LocalIdentity identity = LocalIdentity.generateNew(0);
|
||||||
|
|
||||||
|
Ts3Debugging.debug("Private key: " +
|
||||||
|
Base64.getEncoder().encodeToString(identity.getPrivateKey().toByteArray())
|
||||||
|
);
|
||||||
|
|
||||||
|
identity.improveSecurity(1000);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +1,14 @@
|
|||||||
package com.github.manevolent.ts3j;
|
package com.github.manevolent.ts3j;
|
||||||
|
|
||||||
import com.github.manevolent.ts3j.api.Ban;
|
|
||||||
import com.github.manevolent.ts3j.api.Channel;
|
import com.github.manevolent.ts3j.api.Channel;
|
||||||
import com.github.manevolent.ts3j.api.Client;
|
|
||||||
import com.github.manevolent.ts3j.audio.Microphone;
|
|
||||||
import com.github.manevolent.ts3j.command.SingleCommand;
|
|
||||||
import com.github.manevolent.ts3j.enums.CodecType;
|
|
||||||
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
||||||
import com.github.manevolent.ts3j.identity.Uid;
|
|
||||||
import com.github.manevolent.ts3j.protocol.ProtocolRole;
|
|
||||||
import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
|
import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
|
||||||
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
||||||
import com.github.manevolent.ts3j.util.Ts3Crypt;
|
|
||||||
import com.github.manevolent.ts3j.util.Ts3Debugging;
|
import com.github.manevolent.ts3j.util.Ts3Debugging;
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user