From 484e4a1769dfb790718f550252fa6ef849ba5df9 Mon Sep 17 00:00:00 2001 From: jinmiao Date: Fri, 30 Aug 2019 17:04:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97=E6=89=93?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kcp-base/src/main/java/kcp/RecieveTask.java | 2 +- kcp-base/src/main/java/kcp/ScheduleTask.java | 3 +-- kcp-netty/src/main/java/test/KcpRttExampleClient.java | 9 ++++++++- 3 files changed, 10 insertions(+), 4 deletions(-) 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())); + + }