From 6209d75536f4443afbb5bf3d525782fc4417e137 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 15 Jan 2015 21:33:44 +0100 Subject: [PATCH] Add XMPPTCPConnection.getMaxSmResumptionTime() Note that the logic determining the max resumption time has changed, Math.min() is now used instead of Math.max(). This should match the real life situation, e.g. if the server announced a max resumption time of 10 minutes and the client one of 5, then it should be assumed that the connection/stream state is dropped by the parties after 5 minutes. --- .../jivesoftware/smack/tcp/XMPPTCPConnection.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 1f80523d2..334259254 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -1613,9 +1613,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // See if resumption time is over long current = System.currentTimeMillis(); - int clientResumptionTime = smClientMaxResumptionTime > 0 ? smClientMaxResumptionTime : Integer.MAX_VALUE; - int serverResumptionTime = smServerMaxResumptimTime > 0 ? smServerMaxResumptimTime : Integer.MAX_VALUE; - long maxResumptionMillies = Math.max(clientResumptionTime, serverResumptionTime) * 1000; + long maxResumptionMillies = getMaxSmResumptionTime() * 1000; if (shutdownTimestamp + maxResumptionMillies > current) { return false; } else { @@ -1623,6 +1621,17 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { } } + /** + * Get the maximum resumption time in seconds after which a managed stream can be resumed. + * + * @return the maximum resumption time in seconds. + */ + public int getMaxSmResumptionTime() { + int clientResumptionTime = smClientMaxResumptionTime > 0 ? smClientMaxResumptionTime : Integer.MAX_VALUE; + int serverResumptionTime = smServerMaxResumptimTime > 0 ? smServerMaxResumptimTime : Integer.MAX_VALUE; + return Math.min(clientResumptionTime, serverResumptionTime); + } + private void processHandledCount(long handledCount) throws NotConnectedException { long ackedStanzasCount = SMUtils.calculateDelta(handledCount, serverHandledStanzasCount); final List ackedStanzas = new ArrayList(