Skip to content

Commit

Permalink
Reworked the PingPongTest to use a counter instead of a timer.
Browse files Browse the repository at this point in the history
  • Loading branch information
crykn committed Oct 20, 2018
1 parent e9eb376 commit 08ffb04
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/test/java/com/esotericsoftware/kryonet/PingPongTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
public class PingPongTest extends KryoNetTestCase {
String fail;

int udpCount = 5500;
int tcpCount = 5500;

public void testPingPong() throws IOException {
fail = null;

Expand Down Expand Up @@ -54,13 +57,25 @@ public void received(Connection connection, Object object) {
fail = "TCP data is not equal on server.";
throw new RuntimeException("Fail!");
}
connection.sendTCP(data);
tcpCount--;

if (tcpCount > 0)
connection.sendTCP(data);
else if (udpCount <= 0)
stopEndPoints();
} else {
if (!data.equals(dataUDP)) {

fail = "UDP data is not equal on server.";
throw new RuntimeException("Fail!");
}
connection.sendUDP(data);

udpCount--;

if (udpCount > 0)
connection.sendUDP(data);
else if (tcpCount <= 0)
stopEndPoints();
}
}
}
Expand Down

0 comments on commit 08ffb04

Please sign in to comment.