Browse Source

Major changes

Cleanups and fixes
master
Sogomn 9 years ago
parent
commit
b0e5b63c3f
  1. 4
      Ratty/res/connection_data.txt
  2. 17
      Ratty/src/de/sogomn/rat/Ratty.java
  3. 2
      Ratty/src/de/sogomn/rat/packet/KeyEventPacket.java
  4. 10
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

4
Ratty/res/connection_data.txt

@ -1,3 +1,7 @@
localhost
23456
false
1st line: Address
2nd line: Port
3rd line: True for client; false for server

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

@ -5,8 +5,6 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.JOptionPane;
import com.alee.laf.WebLookAndFeel;
import de.sogomn.engine.util.FileUtils;
@ -39,9 +37,9 @@ public final class Ratty {
final String[] lines = FileUtils.readInternalLines(CONNECTION_DATA_FILE_NAME);
if (lines.length >= 3) {
final String addressString = lines[0];
final String portString = lines[1];
final String clientString = lines[2];
final String addressString = lines[0].trim();
final String portString = lines[1].trim();
final String clientString = lines[2].trim();
address = addressString;
port = Integer.parseInt(portString);
@ -101,16 +99,7 @@ public final class Ratty {
addToStartup();
connectToHost(address, port);
} else {
final String[] options = {"Server", "Client"};
final int input = JOptionPane.showOptionDialog(null, "Server or client?", null, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null);
if (input == JOptionPane.YES_OPTION) {
System.out.println("Server");
startServer(port);
} else if (input == JOptionPane.NO_OPTION) {
connectToHost(address, port);
}
}
}

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

@ -49,8 +49,6 @@ public final class KeyEventPacket implements IPacket {
rob.keyPress(key);
rob.keyRelease(key);
}
System.out.println("Yeh");
} catch (final IllegalArgumentException ex) {
System.err.println("No valid key code");
} catch (final AWTException ex) {

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

@ -32,7 +32,6 @@ import de.sogomn.rat.util.FrameEncoder.IFrame;
* THIS CLASS IS A MESS!
* I HAVE NO IDEA HOW ONE MAKES NON-MESSY CONTROLLER CLASSES
*/
public final class RattyGuiController implements IServerObserver, IClientObserver, IGuiController {
private RattyGui gui;
@ -71,6 +70,8 @@ public final class RattyGuiController implements IServerObserver, IClientObserve
}
private IPacket getPacket(final String command, final ServerClient serverClient) {
final boolean streamingDesktop = serverClient.isStreamingDesktop();
IPacket packet = null;
if (command == RattyGui.POPUP) {
@ -127,12 +128,12 @@ public final class RattyGuiController implements IServerObserver, IClientObserve
packet = new DeleteFilePacket(path);
treePanel.removeFile(path);
} else if (command == DisplayPanel.KEY_PRESSED) {
} else if (command == DisplayPanel.KEY_PRESSED && streamingDesktop) {
final DisplayPanel displayPanel = serverClient.getDisplayPanel();
final int key = displayPanel.getLastKeyHit();
packet = new KeyEventPacket(key, KeyEventPacket.PRESS);
} else if (command == DisplayPanel.KEY_RELEASED) {
} else if (command == DisplayPanel.KEY_RELEASED && streamingDesktop) {
final DisplayPanel displayPanel = serverClient.getDisplayPanel();
final int key = displayPanel.getLastKeyHit();
@ -216,6 +217,9 @@ public final class RattyGuiController implements IServerObserver, IClientObserve
final ServerClient serverClient = getServerClient(client);
final FileTreePanel treePanel = serverClient.getTreePanel();
serverClient.setStreamingDesktop(false);
serverClient.setController(null);
client.setObserver(null);
client.close();
clients.remove(client);

Loading…
Cancel
Save