Ping(back) works on both client and server side.

This commit is contained in:
Jonas 2022-03-27 11:58:48 +02:00
parent 146ff4ea82
commit 63a8e21f6c
3 changed files with 1 additions and 6 deletions

View File

@ -142,10 +142,9 @@ public class Client {
socket = new Socket(hostname, 42069);
Client client = new Client(socket, username);
client.chatListener();
client.sendMessage();
Thread cP = new Thread(client.clientPinger);
System.out.println("im here");
cP.start();
client.sendMessage(); //this one blocks.
} catch (UnknownHostException e) {
System.out.println("Invalid host IP");
} catch (IOException e) {

View File

@ -20,11 +20,9 @@ public class JClientProtocolParser {
switch (header) {
case "SPING":
c.sendMsgToServer("PINGB");
System.out.println("got ping!"); //todo:delete
break;
case "PINGB":
c.clientPinger.setGotPingBack(true);
System.out.println("got pingback!"); //todo: delete
break;
default:
System.out.println("Received unknown command");

View File

@ -24,11 +24,9 @@ public class JServerProtocolParser {
break;
case "CPING":
h.sendMsgToClient("PINGB");
System.out.println("got ping!"); //todo:delete
break;
case "PINGB":
h.serverPinger.setGotPingBack(true);
System.out.println("got pingback!"); //todo: delete
break;
case "QUITS":
h.closeEverything(h.getSocket(), h.getIn(), h.getOut());