refactored a lot and added possibility to play games on DedicatedServer (#43)

This commit is contained in:
Valentin Heiserer
2024-04-19 16:15:51 +02:00
committed by GitHub
parent 6259d0bef3
commit cab2d36f48
31 changed files with 492 additions and 155 deletions

View File

@@ -0,0 +1,26 @@
package org.schafkopf;
import java.util.Timer;
import java.util.TimerTask;
/** Creates an Instance of the Backend Server. */
public class HeartbeatSender {
private static final int HEARTBEAT_INTERVAL = 15000; // 1 minute
private final DedicatedServerConnection client;
public HeartbeatSender(DedicatedServerConnection client) {
this.client = client;
}
/** Creates an Instance of the Backend Server. */
public void start() {
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
client.sendMessage("HEARTBEAT SYN"); // Send a heartbeat message
}
}, HEARTBEAT_INTERVAL, HEARTBEAT_INTERVAL);
}
}