diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/packet/statistics/PacketStatistics.java b/src/main/java/com/github/manevolent/ts3j/protocol/packet/statistics/PacketStatistics.java index 72a0d89..76c6bfd 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/packet/statistics/PacketStatistics.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/packet/statistics/PacketStatistics.java @@ -21,9 +21,9 @@ public class PacketStatistics { receivedBytes += size; receivedPackets ++; - receivedPacketList.add(new DataPoint(packet.getCreatedNanotime() / 1000L, packet.getSize())); + receivedPacketList.add(new DataPoint(packet.getCreatedNanotime(), packet.getSize())); - long t = System.currentTimeMillis() - 60_000L; + long t = System.nanoTime() - 60_000_000_000L; receivedPacketList.removeIf(x -> x.getTime() < t); } @@ -33,10 +33,10 @@ public class PacketStatistics { sentBytes += size; sentPackets ++; - sentPacketList.add(new DataPoint(packet.getCreatedNanotime() / 1000L, packet.getSize())); + sentPacketList.add(new DataPoint(packet.getCreatedNanotime(), packet.getSize())); // Remove oldest - long t = System.currentTimeMillis() - 60_000L; + long t = System.nanoTime() - 60_000_000_000L; sentPacketList.removeIf(x -> x.getTime() < t); } @@ -49,7 +49,7 @@ public class PacketStatistics { } public int getSentPacketsLastSecond() { - long now = System.currentTimeMillis() - 1_000L; + long now = System.currentTimeMillis() - 1_000_000_000L; return (int) sentPacketList.stream() .filter(x -> x.getTime() >= now) @@ -57,7 +57,7 @@ public class PacketStatistics { } public int getSentPacketsLastMinute() { - long now = System.currentTimeMillis() - 60_000L; + long now = System.currentTimeMillis() - 1_000_000_000L; return (int) sentPacketList.stream() .filter(x -> x.getTime() >= now) @@ -69,7 +69,7 @@ public class PacketStatistics { } public int getReceivedPacketsLastSecond() { - long now = System.currentTimeMillis() - 1_000L; + long now = System.currentTimeMillis() - 1_000_000_000L; return (int) receivedPacketList.stream() .filter(x -> x.getTime() >= now) @@ -77,7 +77,7 @@ public class PacketStatistics { } public int getReceivedPacketsLastMinute() { - long now = System.currentTimeMillis() - 60_000L; + long now = System.currentTimeMillis() - 60_000_000_000L; return (int) receivedPacketList.stream() .filter(x -> x.getTime() >= now) @@ -90,7 +90,7 @@ public class PacketStatistics { } public int getSentBytesLastMinute() { - long now = System.currentTimeMillis() - 60_000L; + long now = System.currentTimeMillis() - 60_000_000_000L; return sentPacketList.stream() .filter(x -> x.getTime() >= now) @@ -100,7 +100,7 @@ public class PacketStatistics { } public int getSentBytesLastSecond() { - long now = System.currentTimeMillis() - 1_000L; + long now = System.currentTimeMillis() - 1_000_000_000L; return sentPacketList.stream() .filter(x -> x.getTime() >= now) @@ -110,7 +110,7 @@ public class PacketStatistics { } public int getReceivedBytesLastMinute() { - long now = System.currentTimeMillis() - 60_000L; + long now = System.currentTimeMillis() - 60_000_000_000L; return receivedPacketList.stream() .filter(x -> x.getTime() >= now) @@ -120,7 +120,7 @@ public class PacketStatistics { } public int getReceivedBytesLastSecond() { - long now = System.currentTimeMillis() - 1_000L; + long now = System.currentTimeMillis() - 1_000_000_000L; return receivedPacketList.stream() .filter(x -> x.getTime() >= now) diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java index 0a631a3..f609409 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java @@ -112,9 +112,9 @@ public class LocalTeamspeakClientSocket Pair ping = getPing(); response.add(new CommandSingleParameter("connection_ping", - Integer.toString((int)(double)ping.getKey()))); + Double.toString(Math.round(ping.getKey() * 1000D * 1000D) / 1000D))); response.add(new CommandSingleParameter("connection_ping_deviation", - Integer.toString((int)(double)ping.getValue()))); + Double.toString(Math.round(ping.getValue() * 1000D * 1000D) / 1000D))); for (PacketKind kind : PacketKind.values()) { PacketStatistics stats = getStatistics(kind); diff --git a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java index 8b2729a..e327f15 100644 --- a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java +++ b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java @@ -143,9 +143,7 @@ public class ServerConnectionTest { @Override public void onChannelSubscribed(ChannelSubscribedEvent e) { - System.err.println("doing"); - client.setNickname("EEEE" + (new Random().nextInt(1000))); - System.err.println("done"); + } });