From 968cb94f21413643600ecbeaf4c4efd99c8aeaa3 Mon Sep 17 00:00:00 2001 From: Sebastian Lenzlinger Date: Fri, 8 Apr 2022 16:12:19 +0200 Subject: [PATCH] Now the client disconnects if: 1. no pingback recieved 2. isConnected has already been set to false In this case it looks to be a case where the client isn't responding correctly and the server may close the connection. Added a debog log statement at the respective place. --- .../dmi/dbis/cs108/multiplayer/helpers/ServerPinger.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/helpers/ServerPinger.java b/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/helpers/ServerPinger.java index 88e44f2..34da9e0 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/helpers/ServerPinger.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/helpers/ServerPinger.java @@ -14,6 +14,7 @@ import org.apache.logging.log4j.Logger; * how the server receives and parses messages. */ public class ServerPinger implements Runnable { + public static final Logger LOGGER = LogManager.getLogger(); public static final BudaLogConfig l = new BudaLogConfig(LOGGER); @@ -50,7 +51,13 @@ public class ServerPinger implements Runnable { } else { if (isConnected) { isConnected = false; - System.out.println("Lost connection to user " + c.getClientUserName() + ". Waiting to reconnect..."); + //TODO: Possibly an incorrect statement since this can also happen if a client is not adhearing to the protocol + System.out.println( + "Lost connection to user " + c.getClientUserName() + ". Waiting to reconnect..."); + } else { + c.disconnectClient(); + LOGGER.debug( + "gotPingBack has not been set to true and isConnected has been set to false before"); } } }