好。我收到一次数据包,但它的块被解雇了两次。例如:
我有一个像这样的块:
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);
}
});
}
在控制台(LOG_TRACE)中我可以看到,数据包是在ONCE收到的,但是" STARTTTTTTTTTTTTTTTT" System.out显示两次,倒计时显示两次等。
我不想发布整个代码,导致代码庞大且难以理解。可能这是由于服务器上的缓冲区溢出造成的,或者可能是因为我在一台设备上同时打开了两个连接?如果有任何经验丰富的Kryonet人,我将非常感谢您的帮助。
答案 0 :(得分:0)
注册多个侦听器(游戏完成后应为null)。