Delete: unused test
This commit is contained in:
@@ -69,7 +69,7 @@ public class GameController {
|
||||
*
|
||||
* @return the game model managed by this controller.
|
||||
*/
|
||||
public Game getModel() {
|
||||
public synchronized Game getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class GameController {
|
||||
*
|
||||
* @param model the new game model managed by this controller.
|
||||
*/
|
||||
public void setModel(Game model) {
|
||||
public synchronized void setModel(Game model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
|
||||
@@ -415,6 +415,8 @@ public class Game implements Serializable {
|
||||
case 5:
|
||||
orderLogicCard=new Order5(playersList);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("nPlayers must be 2–5, got: " + nPlayers);
|
||||
}
|
||||
for(Player player : playersList)
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ public class RMIClient implements IClient {
|
||||
|
||||
/** Scheduler that fires ping() every {@value NetworkConfig#KEEPALIVE_INTERVAL_MS} ms. */
|
||||
private ScheduledExecutorService pingSender;
|
||||
private ExecutorService executor;
|
||||
|
||||
/**
|
||||
* Constructs an RMI client and initializes its connection parameters.
|
||||
@@ -94,7 +95,7 @@ public class RMIClient implements IClient {
|
||||
return t;
|
||||
});
|
||||
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
executor = Executors.newSingleThreadExecutor();
|
||||
pingSender.scheduleAtFixedRate(() -> {
|
||||
Future<?> future = executor.submit(() -> {
|
||||
try {
|
||||
@@ -126,6 +127,7 @@ public class RMIClient implements IClient {
|
||||
if (!running) return;
|
||||
running = false;
|
||||
if (pingSender != null) pingSender.shutdownNow();
|
||||
if (executor != null) executor.shutdownNow();
|
||||
controller.setModel(null);
|
||||
controller.setClient(null);
|
||||
}
|
||||
@@ -248,7 +250,8 @@ public class RMIClient implements IClient {
|
||||
* the keep-alive scheduler.
|
||||
*/
|
||||
public void notifyDisconnection() {
|
||||
pingSender.shutdownNow();
|
||||
if (pingSender != null) pingSender.shutdownNow();
|
||||
if (executor != null) executor.shutdownNow();
|
||||
try{
|
||||
stub.disconnectPlayer(username);
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
*/
|
||||
public void disconnectPlayer(String username) {
|
||||
RMIHeartbeat wd = watchdogs.get(username);
|
||||
wd.disconnect();
|
||||
if (wd != null) wd.disconnect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@ public class ClientHandler implements Runnable {
|
||||
out.writeObject(event);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,6 +128,7 @@ public class ClientHandler implements Runnable {
|
||||
out.writeObject(game);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user