Reconnection issues
This commit is contained in:
+42
-41
@@ -1,9 +1,11 @@
|
||||
package com.github.manevolent.ts3j.protocol.packet.handler.client;
|
||||
|
||||
import com.github.manevolent.ts3j.command.Command;
|
||||
import com.github.manevolent.ts3j.command.SingleCommand;
|
||||
import com.github.manevolent.ts3j.command.parameter.CommandSingleParameter;
|
||||
import com.github.manevolent.ts3j.protocol.Packet;
|
||||
import com.github.manevolent.ts3j.protocol.ProtocolRole;
|
||||
import com.github.manevolent.ts3j.protocol.TS3DNS;
|
||||
import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
|
||||
import com.github.manevolent.ts3j.protocol.packet.PacketBody2Command;
|
||||
import com.github.manevolent.ts3j.protocol.packet.PacketBody8Init1;
|
||||
@@ -188,49 +190,48 @@ public class LocalClientHandlerConnecting extends LocalClientHandler {
|
||||
|
||||
alphaBytes = null;
|
||||
|
||||
getClient().writePacket(new PacketBody2Command(
|
||||
Command clientinit = new SingleCommand(
|
||||
"clientinit",
|
||||
ProtocolRole.CLIENT,
|
||||
new SingleCommand(
|
||||
"clientinit",
|
||||
ProtocolRole.CLIENT,
|
||||
new CommandSingleParameter("client_nickname", getClient().getNickname()),
|
||||
new CommandSingleParameter("client_version", "3.?.? [Build: 5680278000]"),
|
||||
new CommandSingleParameter("client_platform", "Windows"),
|
||||
new CommandSingleParameter(
|
||||
"client_version_sign",
|
||||
"DX5NIYLvfJEUjuIbCidnoeozxIDRRkpq3I9vVMBmE9L2qnekOoBzSenkzsg2lC9CMv8K5hkEzhr2TYUYSwUXCg=="
|
||||
),
|
||||
new CommandSingleParameter("client_input_hardware", "1"),
|
||||
new CommandSingleParameter("client_output_hardware", "1"),
|
||||
new CommandSingleParameter("client_default_channel",
|
||||
getClient().getOption("client.default_channel", String.class)
|
||||
),
|
||||
new CommandSingleParameter("client_default_channel_password",
|
||||
getClient().getOption("client.default_channel_password", String.class)
|
||||
),
|
||||
new CommandSingleParameter(
|
||||
"client_server_password",
|
||||
getClient().getOption("client.server_password", String.class)
|
||||
),
|
||||
new CommandSingleParameter("client_nickname_phonetic",
|
||||
getClient().getOption("client.nickname_phonetic", String.class)
|
||||
),
|
||||
new CommandSingleParameter("client_meta_data", ""),
|
||||
new CommandSingleParameter("client_default_token",
|
||||
getClient().getOption("client.default_token", String.class)
|
||||
),
|
||||
new CommandSingleParameter(
|
||||
"client_key_offset",
|
||||
Long.toString(getClient().getIdentity().getKeyOffset())
|
||||
),
|
||||
new CommandSingleParameter(
|
||||
"hwid",
|
||||
getClient().getOption("client.hwid", String.class) != null ?
|
||||
getClient().getOption("client.hwid", String.class) :
|
||||
"+LyYqbDqOvEEpN5pdAbF8/v5kZ0="
|
||||
)
|
||||
new CommandSingleParameter("client_nickname", getClient().getNickname()),
|
||||
new CommandSingleParameter("client_version", "3.?.? [Build: 5680278000]"),
|
||||
new CommandSingleParameter("client_platform", "Windows"),
|
||||
new CommandSingleParameter(
|
||||
"client_version_sign",
|
||||
"DX5NIYLvfJEUjuIbCidnoeozxIDRRkpq3I9vVMBmE9L2qnekOoBzSenkzsg2lC9CMv8K5hkEzhr2TYUYSwUXCg=="
|
||||
),
|
||||
new CommandSingleParameter("client_input_hardware", "1"),
|
||||
new CommandSingleParameter("client_output_hardware", "1"),
|
||||
new CommandSingleParameter("client_default_channel",
|
||||
getClient().getOption("client.default_channel", String.class)
|
||||
),
|
||||
new CommandSingleParameter("client_default_channel_password",
|
||||
getClient().getOption("client.default_channel_password", String.class)
|
||||
),
|
||||
new CommandSingleParameter("client_server_password",
|
||||
getClient().getOption("client.server_password", String.class)
|
||||
),
|
||||
new CommandSingleParameter("client_nickname_phonetic",
|
||||
getClient().getOption("client.nickname_phonetic", String.class)
|
||||
),
|
||||
new CommandSingleParameter("client_meta_data", ""),
|
||||
new CommandSingleParameter("client_default_token",
|
||||
getClient().getOption("client.default_token", String.class)
|
||||
),
|
||||
new CommandSingleParameter("client_key_offset",
|
||||
Long.toString(getClient().getIdentity().getKeyOffset())
|
||||
),
|
||||
new CommandSingleParameter(
|
||||
"hwid",
|
||||
getClient().getOption("client.hwid", String.class) != null ?
|
||||
getClient().getOption("client.hwid", String.class) :
|
||||
"+LyYqbDqOvEEpN5pdAbF8/v5kZ0="
|
||||
)
|
||||
));
|
||||
);
|
||||
|
||||
Ts3Debugging.debug(clientinit.build());
|
||||
|
||||
getClient().writePacket(new PacketBody2Command(ProtocolRole.CLIENT, clientinit));
|
||||
|
||||
getClient().setCommandProcessor(getClient());
|
||||
getClient().setState(ClientConnectionState.RETRIEVING_DATA);
|
||||
|
||||
+22
@@ -1,9 +1,31 @@
|
||||
package com.github.manevolent.ts3j.protocol.packet.handler.client;
|
||||
|
||||
import com.github.manevolent.ts3j.command.CommandProcessException;
|
||||
import com.github.manevolent.ts3j.command.CommandProcessor;
|
||||
import com.github.manevolent.ts3j.command.MultiCommand;
|
||||
import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
|
||||
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
||||
|
||||
|
||||
public class LocalClientHandlerRetrievingData extends LocalClientHandlerFull {
|
||||
public LocalClientHandlerRetrievingData(LocalTeamspeakClientSocket client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleCommand(MultiCommand command) throws CommandProcessException {
|
||||
if (command.getName().equalsIgnoreCase("error")) {
|
||||
try {
|
||||
getClient().setState(ClientConnectionState.DISCONNECTED);
|
||||
} catch (Exception e) {
|
||||
getClient().getExceptionHandler().accept(e);
|
||||
}
|
||||
|
||||
throw new CommandProcessException(command.simplifyOne().get("msg").getValue());
|
||||
}
|
||||
|
||||
CommandProcessor processor = getClient().getCommandProcessor();
|
||||
if (processor != null) processor.process(getClient(), command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-2
@@ -205,8 +205,6 @@ public abstract class AbstractTeamspeakClientSocket
|
||||
}
|
||||
|
||||
protected void onDisconnect() {
|
||||
clientOptions.clear();
|
||||
|
||||
clientId = -1;
|
||||
|
||||
readQueue.clear();
|
||||
|
||||
+8
-1
@@ -260,7 +260,6 @@ public class LocalTeamspeakClientSocket
|
||||
* @param timeout timeout, in milliseconds, to complete a connection.
|
||||
*/
|
||||
public void connect(String hostname, String password, long timeout) throws
|
||||
UnknownHostException,
|
||||
IOException,
|
||||
TimeoutException {
|
||||
|
||||
@@ -651,6 +650,14 @@ public class LocalTeamspeakClientSocket
|
||||
super.setNickname(nickname);
|
||||
}
|
||||
|
||||
public void setHWID(String hwid) {
|
||||
setOption("client.hwid", hwid);
|
||||
}
|
||||
|
||||
public String getHWID() {
|
||||
return getOption("client.hwid", String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Commands
|
||||
*/
|
||||
|
||||
@@ -31,132 +31,25 @@ public class ServerConnectionTest {
|
||||
identity.improveSecurity(10);
|
||||
|
||||
client.setIdentity(identity);
|
||||
|
||||
client.setNickname("Hello from Java");
|
||||
client.setHWID("JAVAJAVAJAVA");
|
||||
|
||||
client.setOption("client.hwid", "JAVAJAVAJAVA");
|
||||
|
||||
client.connect(
|
||||
"teamlixo.net",
|
||||
null,
|
||||
10000L
|
||||
);
|
||||
while (true) {
|
||||
try {
|
||||
|
||||
client.addListener(new TS3Listener() {
|
||||
@Override
|
||||
public void onTextMessage(TextMessageEvent e) {
|
||||
client.connect(
|
||||
"teamlixo.net",
|
||||
null,
|
||||
10000L
|
||||
);
|
||||
|
||||
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientJoin(ClientJoinEvent e) {
|
||||
System.err.println(e.get("cid"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientLeave(ClientLeaveEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServerEdit(ServerEditedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChannelEdit(ChannelEditedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChannelDescriptionChanged(ChannelDescriptionEditedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientMoved(ClientMovedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChannelCreate(ChannelCreateEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChannelDeleted(ChannelDeletedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChannelMoved(ChannelMovedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChannelPasswordChanged(ChannelPasswordChangedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChannelList(ChannelListEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrivilegeKeyUsed(PrivilegeKeyUsedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChannelGroupList(ChannelGroupListEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServerGroupList(ServerGroupListEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientNeededPermissions(ClientNeededPermissionsEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientChannelGroupChanged(ClientChannelGroupChangedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientChanged(ClientUpdatedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected(DisconnectedEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChannelSubscribed(ChannelSubscribedEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
|
||||
|
||||
client.subscribeAll();
|
||||
|
||||
try {
|
||||
client.setVoiceHandler(packetBody0Voice -> {
|
||||
System.err.println("clientId=" + packetBody0Voice.getClientId());
|
||||
System.err.println("packetId=" + packetBody0Voice.getPacketId());
|
||||
System.err.println("type=" + packetBody0Voice.getCodecType());
|
||||
System.err.println("len=" + packetBody0Voice.getCodecData().length);
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
client.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user