diff --git a/kcp-base/src/main/java/kcp/RecieveTask.java b/kcp-base/src/main/java/kcp/RecieveTask.java index 66379e8..9c7fbd5 100644 --- a/kcp-base/src/main/java/kcp/RecieveTask.java +++ b/kcp-base/src/main/java/kcp/RecieveTask.java @@ -79,7 +79,7 @@ public void execute() { } } //判断写事件 - if (kcp.canSend(false)&&!kcp.getSendList().isEmpty()) { + if (!kcp.getSendList().isEmpty()&&kcp.canSend(false)) { kcp.notifyWriteEvent(); } } catch (Throwable e) { diff --git a/kcp-base/src/main/java/kcp/ScheduleTask.java b/kcp-base/src/main/java/kcp/ScheduleTask.java index add3d3a..9187d28 100644 --- a/kcp-base/src/main/java/kcp/ScheduleTask.java +++ b/kcp-base/src/main/java/kcp/ScheduleTask.java @@ -64,8 +64,7 @@ public void execute() { //检测写缓冲区 如果能写则触发写事件 - if(ukcp.canSend(false) - &&!ukcp.getSendList().isEmpty() + if(!ukcp.getSendList().isEmpty()&&ukcp.canSend(false) ){ ukcp.notifyWriteEvent(); } diff --git a/kcp-netty/src/main/java/test/KcpRttExampleClient.java b/kcp-netty/src/main/java/test/KcpRttExampleClient.java index 194a7b4..9c05138 100644 --- a/kcp-netty/src/main/java/test/KcpRttExampleClient.java +++ b/kcp-netty/src/main/java/test/KcpRttExampleClient.java @@ -133,11 +133,18 @@ public void handleClose(Ukcp kcp) { } int sum = 0; + int max = 0; for (int rtt : rtts) { + if(rtt>max){ + max = rtt; + } sum += rtt; } - System.out.println("average: "+ (sum / rtts.length)); + System.out.println("average: "+ (sum / rtts.length)+" max:"+max); System.out.println(Snmp.snmp.toString()); + System.out.println("lost percent: "+(Snmp.snmp.RetransSegs.doubleValue()/Snmp.snmp.OutPkts.doubleValue())); + + }