Merge pull request #22 from Phyrone/master
unknown events will be catched and no longer break the whole client
This commit is contained in:
@@ -88,7 +88,7 @@ public interface TS3Event {
|
||||
case "notifychannelpermhints": // CLIENT
|
||||
return new ChannelPermHintsEvent(command.toMap());
|
||||
default:
|
||||
throw new IllegalArgumentException("unknown event: " + command.getName());
|
||||
return new UnknownTeamspeakEvent(command.getName(),command.toMap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +57,5 @@ public interface TS3Listener {
|
||||
default void onClientChatClosed(ClientChatClosedEvent e) {}
|
||||
default void onClientPermHints(ClientPermHintsEvent e) {}
|
||||
default void onChannelPermHints(ChannelPermHintsEvent e) {}
|
||||
default void onUnknownEvent(UnknownTeamspeakEvent e){}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.github.manevolent.ts3j.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class UnknownTeamspeakEvent extends BaseEvent {
|
||||
String command;
|
||||
|
||||
public UnknownTeamspeakEvent(String command, Map<String, String> map) {
|
||||
super(map);
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fire(TS3Listener listener) {
|
||||
listener.onUnknownEvent(this);
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -434,7 +434,6 @@ public class LocalTeamspeakClientSocket
|
||||
processor.process(client, singleCommand);
|
||||
} else if (singleCommand.getName().startsWith("notify")) {
|
||||
TS3Event event = TS3Event.createEvent(singleCommand);
|
||||
|
||||
commandExecutionService.submit(() -> listeners.forEach(event::fire));
|
||||
} else {
|
||||
CommandProcessor awaitingCommandProcessor;
|
||||
@@ -521,9 +520,9 @@ public class LocalTeamspeakClientSocket
|
||||
|
||||
if (microphone != null && microphoneThread == null) {
|
||||
microphoneThread = new HighPrecisionTimer(
|
||||
20,
|
||||
5F, // up to 100ms of drift/catchup
|
||||
new MicrophoneTask()
|
||||
20,
|
||||
5F, // up to 100ms of drift/catchup
|
||||
new MicrophoneTask()
|
||||
);
|
||||
microphoneThread.setDaemon(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user