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); Thread.currentThread().setPriority(10);
try { try {
Thread.sleep(20000); Thread.sleep(20000);
} catch (InterruptedException e) { while (socket.isConnected() && !socket.isClosed()) {
Thread.currentThread().interrupt(); gotPingBack = false;
} client.sendMsgToServer(Protocol.pingFromClient);
while (socket.isConnected() && !socket.isClosed()) {
gotPingBack = false;
client.sendMsgToServer(Protocol.pingFromClient);
try {
Thread.sleep(4000); Thread.sleep(4000);
} catch (InterruptedException e) { if (gotPingBack) {
Thread.currentThread().interrupt(); if (!isConnected) { //if !isConnected, then the connection had been lost before.
} isConnected = true;
if (gotPingBack) { System.out.println("Connection regained!");
if (!isConnected) { //if !isConnected, then the connection had been lost before. }
isConnected = true; } else {
System.out.println("Connection regained!"); if (isConnected) {
} isConnected = false;
} else { System.out.println("Lost connection. Waiting to reconnect...");
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) { public void setGotPingBack(boolean gotPingBack) {