summaryrefslogtreecommitdiffstats
blob: 5b71f910b2d33a2a3f4e2fa8c89ce6a36f2a01d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * Copyright (c) 2010 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#include "Swiften/StreamManagement/StanzaAckResponder.h"

#include <boost/numeric/conversion/cast.hpp>

namespace Swift {

static const unsigned int MAX_HANDLED_STANZA_COUNT = boost::numeric_cast<unsigned int>((1ULL<<32) - 1);

StanzaAckResponder::StanzaAckResponder() : handledStanzasCount(0) {
}

void StanzaAckResponder::handleStanzaReceived() {
	handledStanzasCount = (handledStanzasCount == MAX_HANDLED_STANZA_COUNT ? 0 : handledStanzasCount + 1);
}

void StanzaAckResponder::handleAckRequestReceived() {
	onAck(handledStanzasCount);
}

}