private void resetState(String state, long transitionTime) { if (isConnected()) { totalTimeConnected += (System.currentTimeMillis() - this.transitionTime); } this.state = state; this.transitionTime = transitionTime; }
void clientLeaseRenewed(long lastLeaseRenewalTime, long lease) { this.numLeaseRenewals++; this.lease = lease; this.lastLeaseRenewalTime = System.currentTimeMillis(); if (!isConnected()) { resetState(CONNECTED, lastLeaseRenewalTime); } }
/** * Get the duration of current connection relative to local clock (from transition time) <br> * <br> * <B>Note:</B> This assumes the clocks are in sync with the reporting peer * * @see #getTotalTimeConnected(long) * @return time in ms (see note above) or 0 if not connected */ public long getTimeConnected() { return getTimeConnected(System.currentTimeMillis()); }