1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 21:42:07 +01:00

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.
This commit is contained in:
Florian Schmaus 2015-01-15 21:33:44 +01:00
parent 04d47b2dda
commit 6209d75536

View file

@ -1613,9 +1613,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// See if resumption time is over // See if resumption time is over
long current = System.currentTimeMillis(); long current = System.currentTimeMillis();
int clientResumptionTime = smClientMaxResumptionTime > 0 ? smClientMaxResumptionTime : Integer.MAX_VALUE; long maxResumptionMillies = getMaxSmResumptionTime() * 1000;
int serverResumptionTime = smServerMaxResumptimTime > 0 ? smServerMaxResumptimTime : Integer.MAX_VALUE;
long maxResumptionMillies = Math.max(clientResumptionTime, serverResumptionTime) * 1000;
if (shutdownTimestamp + maxResumptionMillies > current) { if (shutdownTimestamp + maxResumptionMillies > current) {
return false; return false;
} else { } 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 { private void processHandledCount(long handledCount) throws NotConnectedException {
long ackedStanzasCount = SMUtils.calculateDelta(handledCount, serverHandledStanzasCount); long ackedStanzasCount = SMUtils.calculateDelta(handledCount, serverHandledStanzasCount);
final List<Packet> ackedStanzas = new ArrayList<Packet>( final List<Packet> ackedStanzas = new ArrayList<Packet>(