diff options
author | Andrew Comminos <andrewcomminos@gmail.com> | 2014-01-02 06:19:19 +0400 |
---|---|---|
committer | Andrew Comminos <andrewcomminos@gmail.com> | 2014-01-02 06:19:19 +0400 |
commit | db231f232452fc195323a8cf0afb2f9a12f8f5c9 (patch) | |
tree | a1d89bf18efcb9f692a9c2d2895ff610f4426a18 /src/main/java | |
parent | b5f911af43e9b0e4969e4a70ad8ba8f890601011 (diff) |
Report latest TCP ping time.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/morlunk/jumble/net/JumbleConnection.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/com/morlunk/jumble/net/JumbleConnection.java b/src/main/java/com/morlunk/jumble/net/JumbleConnection.java index 1b728bd..6e7ee34 100644 --- a/src/main/java/com/morlunk/jumble/net/JumbleConnection.java +++ b/src/main/java/com/morlunk/jumble/net/JumbleConnection.java @@ -101,6 +101,7 @@ public class JumbleConnection { // Latency private long mLastUDPPing; + private long mLastTCPPing; // Server private Server mServer; @@ -108,6 +109,7 @@ public class JumbleConnection { private String mServerRelease; private String mServerOSName; private String mServerOSVersion; + private int mMaxBandwidth; // Session private int mSession; @@ -133,6 +135,7 @@ public class JumbleConnection { mPingTask = mPingExecutorService.scheduleAtFixedRate(mPingRunnable, 0, 5, TimeUnit.SECONDS); mSession = msg.getSession(); + mMaxBandwidth = msg.getMaxBandwidth(); mSynchronized = true; mMainHandler.post(new Runnable() { @@ -203,6 +206,7 @@ public class JumbleConnection { // In microseconds long elapsed = getElapsed(); + mLastTCPPing = elapsed-msg.getTimestamp(); if(((mCryptState.mUiRemoteGood == 0) || (mCryptState.mUiGood == 0)) && mUsingUDP && elapsed > 20000000) { mUsingUDP = false; @@ -230,8 +234,8 @@ public class JumbleConnection { buffer.put(timedata); buffer.flip(); - long timestamp = (long) (buffer.getLong() * Math.pow(10, 3)); // um -> nm - long now = System.nanoTime()-mStartTimestamp; + long timestamp = buffer.getLong(); + long now = getElapsed(); mLastUDPPing = now-timestamp; // TODO refresh UDP? } @@ -354,7 +358,7 @@ public class JumbleConnection { } public long getTCPLatency() { - return 0; + return mLastTCPPing; } public long getUDPLatency() { @@ -365,6 +369,10 @@ public class JumbleConnection { return mSession; } + public int getMaxBandwidth() { + return mMaxBandwidth; + } + /** * Gracefully shuts down all networking. Blocks until all network threads have stopped. */ |