Reconnection issues
This commit is contained in:
+10
-9
@@ -1,9 +1,11 @@
|
|||||||
package com.github.manevolent.ts3j.protocol.packet.handler.client;
|
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.SingleCommand;
|
||||||
import com.github.manevolent.ts3j.command.parameter.CommandSingleParameter;
|
import com.github.manevolent.ts3j.command.parameter.CommandSingleParameter;
|
||||||
import com.github.manevolent.ts3j.protocol.Packet;
|
import com.github.manevolent.ts3j.protocol.Packet;
|
||||||
import com.github.manevolent.ts3j.protocol.ProtocolRole;
|
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.client.ClientConnectionState;
|
||||||
import com.github.manevolent.ts3j.protocol.packet.PacketBody2Command;
|
import com.github.manevolent.ts3j.protocol.packet.PacketBody2Command;
|
||||||
import com.github.manevolent.ts3j.protocol.packet.PacketBody8Init1;
|
import com.github.manevolent.ts3j.protocol.packet.PacketBody8Init1;
|
||||||
@@ -188,9 +190,7 @@ public class LocalClientHandlerConnecting extends LocalClientHandler {
|
|||||||
|
|
||||||
alphaBytes = null;
|
alphaBytes = null;
|
||||||
|
|
||||||
getClient().writePacket(new PacketBody2Command(
|
Command clientinit = new SingleCommand(
|
||||||
ProtocolRole.CLIENT,
|
|
||||||
new SingleCommand(
|
|
||||||
"clientinit",
|
"clientinit",
|
||||||
ProtocolRole.CLIENT,
|
ProtocolRole.CLIENT,
|
||||||
new CommandSingleParameter("client_nickname", getClient().getNickname()),
|
new CommandSingleParameter("client_nickname", getClient().getNickname()),
|
||||||
@@ -208,8 +208,7 @@ public class LocalClientHandlerConnecting extends LocalClientHandler {
|
|||||||
new CommandSingleParameter("client_default_channel_password",
|
new CommandSingleParameter("client_default_channel_password",
|
||||||
getClient().getOption("client.default_channel_password", String.class)
|
getClient().getOption("client.default_channel_password", String.class)
|
||||||
),
|
),
|
||||||
new CommandSingleParameter(
|
new CommandSingleParameter("client_server_password",
|
||||||
"client_server_password",
|
|
||||||
getClient().getOption("client.server_password", String.class)
|
getClient().getOption("client.server_password", String.class)
|
||||||
),
|
),
|
||||||
new CommandSingleParameter("client_nickname_phonetic",
|
new CommandSingleParameter("client_nickname_phonetic",
|
||||||
@@ -219,8 +218,7 @@ public class LocalClientHandlerConnecting extends LocalClientHandler {
|
|||||||
new CommandSingleParameter("client_default_token",
|
new CommandSingleParameter("client_default_token",
|
||||||
getClient().getOption("client.default_token", String.class)
|
getClient().getOption("client.default_token", String.class)
|
||||||
),
|
),
|
||||||
new CommandSingleParameter(
|
new CommandSingleParameter("client_key_offset",
|
||||||
"client_key_offset",
|
|
||||||
Long.toString(getClient().getIdentity().getKeyOffset())
|
Long.toString(getClient().getIdentity().getKeyOffset())
|
||||||
),
|
),
|
||||||
new CommandSingleParameter(
|
new CommandSingleParameter(
|
||||||
@@ -229,8 +227,11 @@ public class LocalClientHandlerConnecting extends LocalClientHandler {
|
|||||||
getClient().getOption("client.hwid", String.class) :
|
getClient().getOption("client.hwid", String.class) :
|
||||||
"+LyYqbDqOvEEpN5pdAbF8/v5kZ0="
|
"+LyYqbDqOvEEpN5pdAbF8/v5kZ0="
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
));
|
|
||||||
|
Ts3Debugging.debug(clientinit.build());
|
||||||
|
|
||||||
|
getClient().writePacket(new PacketBody2Command(ProtocolRole.CLIENT, clientinit));
|
||||||
|
|
||||||
getClient().setCommandProcessor(getClient());
|
getClient().setCommandProcessor(getClient());
|
||||||
getClient().setState(ClientConnectionState.RETRIEVING_DATA);
|
getClient().setState(ClientConnectionState.RETRIEVING_DATA);
|
||||||
|
|||||||
+22
@@ -1,9 +1,31 @@
|
|||||||
package com.github.manevolent.ts3j.protocol.packet.handler.client;
|
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;
|
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
||||||
|
|
||||||
|
|
||||||
public class LocalClientHandlerRetrievingData extends LocalClientHandlerFull {
|
public class LocalClientHandlerRetrievingData extends LocalClientHandlerFull {
|
||||||
public LocalClientHandlerRetrievingData(LocalTeamspeakClientSocket client) {
|
public LocalClientHandlerRetrievingData(LocalTeamspeakClientSocket client) {
|
||||||
super(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() {
|
protected void onDisconnect() {
|
||||||
clientOptions.clear();
|
|
||||||
|
|
||||||
clientId = -1;
|
clientId = -1;
|
||||||
|
|
||||||
readQueue.clear();
|
readQueue.clear();
|
||||||
|
|||||||
+8
-1
@@ -260,7 +260,6 @@ public class LocalTeamspeakClientSocket
|
|||||||
* @param timeout timeout, in milliseconds, to complete a connection.
|
* @param timeout timeout, in milliseconds, to complete a connection.
|
||||||
*/
|
*/
|
||||||
public void connect(String hostname, String password, long timeout) throws
|
public void connect(String hostname, String password, long timeout) throws
|
||||||
UnknownHostException,
|
|
||||||
IOException,
|
IOException,
|
||||||
TimeoutException {
|
TimeoutException {
|
||||||
|
|
||||||
@@ -651,6 +650,14 @@ public class LocalTeamspeakClientSocket
|
|||||||
super.setNickname(nickname);
|
super.setNickname(nickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHWID(String hwid) {
|
||||||
|
setOption("client.hwid", hwid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHWID() {
|
||||||
|
return getOption("client.hwid", String.class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commands
|
* Commands
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -31,10 +31,12 @@ public class ServerConnectionTest {
|
|||||||
identity.improveSecurity(10);
|
identity.improveSecurity(10);
|
||||||
|
|
||||||
client.setIdentity(identity);
|
client.setIdentity(identity);
|
||||||
|
|
||||||
client.setNickname("Hello from Java");
|
client.setNickname("Hello from Java");
|
||||||
|
client.setHWID("JAVAJAVAJAVA");
|
||||||
|
|
||||||
client.setOption("client.hwid", "JAVAJAVAJAVA");
|
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
|
||||||
client.connect(
|
client.connect(
|
||||||
"teamlixo.net",
|
"teamlixo.net",
|
||||||
@@ -42,121 +44,12 @@ public class ServerConnectionTest {
|
|||||||
10000L
|
10000L
|
||||||
);
|
);
|
||||||
|
|
||||||
client.addListener(new TS3Listener() {
|
|
||||||
@Override
|
|
||||||
public void onTextMessage(TextMessageEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
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) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user