summaryrefslogtreecommitdiffstats
blob: 7c4fd22fa8ae36ba6e0fd593a98328edb14f03a9 (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
27
28
29
/*
 * Copyright (c) 2011 Isode Limited, London, England.
 * All rights reserved.
 */
/*
 * Copyright (c) 2010 Remko Tronçon.
 * All rights reserved.
 */
package com.isode.stroke.streammanagement;

import com.isode.stroke.signals.Signal1;

public class StanzaAckResponder {

    static final long MAX_HANDLED_STANZA_COUNT = Long.parseLong("4294967295"); //boost::numeric_cast<unsigned int>((1ULL<<32) - 1);

    public StanzaAckResponder() {
    }

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

    public void handleAckRequestReceived() {
        onAck.emit(handledStanzasCount);
    }
    public Signal1<Long> onAck = new Signal1<Long>();
    long handledStanzasCount = 0;
}