Removed interruption from pinger

This commit is contained in:
Seraina 2022-04-09 11:52:20 +02:00
parent 67cd93403a
commit d45d64a9c7

View File

@ -38,30 +38,26 @@ public class ClientPinger implements Runnable {
Thread.currentThread().setPriority(10);
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
while (socket.isConnected() && !socket.isClosed()) {
gotPingBack = false;
client.sendMsgToServer(Protocol.pingFromClient);
try {
while (socket.isConnected() && !socket.isClosed()) {
gotPingBack = false;
client.sendMsgToServer(Protocol.pingFromClient);
Thread.sleep(4000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
if (gotPingBack) {
if (!isConnected) { //if !isConnected, then the connection had been lost before.
isConnected = true;
System.out.println("Connection regained!");
}
} else {
if (isConnected) {
isConnected = false;
System.out.println("Lost connection. Waiting to reconnect...");
if (gotPingBack) {
if (!isConnected) { //if !isConnected, then the connection had been lost before.
isConnected = true;
System.out.println("Connection regained!");
}
} else {
if (isConnected) {
isConnected = false;
System.out.println("Lost connection. Waiting to reconnect...");
}
}
}
isConnected = false;
} catch (InterruptedException e) {
e.printStackTrace();
}
isConnected = false;
}
public void setGotPingBack(boolean gotPingBack) {