Okay. I am receiving packet once, but it's block is fired twice. For example:
I have a block like this:
if (object instanceof InitTheGame) {
System.out.println("STARTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT");
awaitOpponent.dismiss();
isInQueue = false;
matchRunning = true; // handles the while loop inside the thread that sends data to the server
isInMatch = true; // handles view (checks for this if we exit the app)
// new GamePacketSender().start();
casualGameHolder.gameLoop.start();
new Sensor(act, casualGameHolder.gameLoop);
touchListener = new TouchListener(casualGameHolder.gameLoop);
this_layout.setOnTouchListener(touchListener);
act.runOnUiThread(new Runnable() {
public void run() {
GameStartCountdown countdown = new GameStartCountdown(4000,1000);
countdown.start();
countdownDialog = new Dialog(act);
countdownDialog.show();
countdownDialog.setCancelable(false);
}
});
}
In console (LOG_TRACE) I can see, that the packet was received ONCE, but the "STARTTTTTTTTTTTTTTTTT" System.out is shown twice, countdown is shown twice etc.
I don't want to post the whole code, cause it's huge and hard to understand. May this caused by overflowing the buffer on the server, or maybe by this that I have SOMEHOW two connections opened at the same time on one device? If there is any experienced person with Kryonet, I would be grateful for help.
Caused by registering multiple listeners (should be null after the game is complete).