Exposed voice packets to the client

This commit is contained in:
Manevolent
2018-08-15 11:43:41 -04:00
parent 1038780e68
commit 83e59ab6e9
4 changed files with 18 additions and 29 deletions
@@ -26,6 +26,8 @@ package com.github.manevolent.ts3j.event;
* #L% * #L%
*/ */
import com.github.manevolent.ts3j.audio.Microphone;
public interface TS3Listener { public interface TS3Listener {
void onTextMessage(TextMessageEvent e); void onTextMessage(TextMessageEvent e);
@@ -67,4 +69,5 @@ public interface TS3Listener {
void onDisconnected(DisconnectedEvent e); void onDisconnected(DisconnectedEvent e);
void onChannelSubscribed(ChannelSubscribedEvent e); void onChannelSubscribed(ChannelSubscribedEvent e);
} }
@@ -1,29 +0,0 @@
package com.github.manevolent.ts3j.event;
public interface TeamspeakListener {
void onTextMessage(TextMessageEvent e);
void onClientJoin(ClientJoinEvent e);
void onClientLeave(ClientLeaveEvent e);
void onServerEdit(ServerEditedEvent e);
void onChannelEdit(ChannelEditedEvent e);
void onChannelDescriptionChanged(ChannelDescriptionEditedEvent e);
void onClientMoved(ClientMovedEvent e);
void onChannelCreate(ChannelCreateEvent e);
void onChannelDeleted(ChannelDeletedEvent e);
void onChannelMoved(ChannelMovedEvent e);
void onChannelPasswordChanged(ChannelPasswordChangedEvent e);
void onPrivilegeKeyUsed(PrivilegeKeyUsedEvent e);
}
@@ -4,6 +4,7 @@ import com.github.manevolent.ts3j.command.CommandProcessException;
import com.github.manevolent.ts3j.command.CommandProcessor; import com.github.manevolent.ts3j.command.CommandProcessor;
import com.github.manevolent.ts3j.command.MultiCommand; import com.github.manevolent.ts3j.command.MultiCommand;
import com.github.manevolent.ts3j.protocol.Packet; import com.github.manevolent.ts3j.protocol.Packet;
import com.github.manevolent.ts3j.protocol.packet.PacketBody0Voice;
import com.github.manevolent.ts3j.protocol.packet.PacketBody2Command; import com.github.manevolent.ts3j.protocol.packet.PacketBody2Command;
import com.github.manevolent.ts3j.protocol.packet.PacketBody3CommandLow; import com.github.manevolent.ts3j.protocol.packet.PacketBody3CommandLow;
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket; import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
@@ -11,6 +12,7 @@ import com.github.manevolent.ts3j.util.Ts3Debugging;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
public abstract class LocalClientHandlerFull extends LocalClientHandler { public abstract class LocalClientHandlerFull extends LocalClientHandler {
protected LocalClientHandlerFull(LocalTeamspeakClientSocket client) { protected LocalClientHandlerFull(LocalTeamspeakClientSocket client) {
@@ -50,6 +52,10 @@ public abstract class LocalClientHandlerFull extends LocalClientHandler {
throw new IOException(e); throw new IOException(e);
} }
break;
case VOICE:
Consumer<PacketBody0Voice> handler = getClient().getVoiceHandler();
if (handler != null) handler.accept((PacketBody0Voice) packet.getBody());
break; break;
} }
} }
@@ -69,6 +69,7 @@ public abstract class AbstractTeamspeakClientSocket
private CommandProcessor commandProcessor; private CommandProcessor commandProcessor;
private Consumer<PacketBody0Voice> voiceHandler;
private Consumer<Throwable> exceptionHandler = Throwable::printStackTrace; private Consumer<Throwable> exceptionHandler = Throwable::printStackTrace;
private Identity identity = null; private Identity identity = null;
@@ -877,6 +878,14 @@ public abstract class AbstractTeamspeakClientSocket
this.exceptionHandler = exceptionHandler; this.exceptionHandler = exceptionHandler;
} }
public Consumer<PacketBody0Voice> getVoiceHandler() {
return voiceHandler;
}
public void setVoiceHandler(Consumer<PacketBody0Voice> voiceHandler) {
this.voiceHandler = voiceHandler;
}
private class NetworkHandler implements Runnable { private class NetworkHandler implements Runnable {
@Override @Override
public void run() { public void run() {