diff options
author | Tarun Gupta <tarun1995gupta@gmail.com> | 2015-07-28 11:26:53 (GMT) |
---|---|---|
committer | Alex Clayton <alex.clayton@isode.com> | 2016-01-14 15:13:35 (GMT) |
commit | 701abcb162dfb3e7cc8c6a9ada81a16d1fc8d4ee (patch) | |
tree | 64f49648eefdca1e2245b6899a3b49e428063f13 /src/com/isode | |
parent | c72128ba30a386704244322c15146a1b4a609a12 (diff) | |
download | stroke-701abcb162dfb3e7cc8c6a9ada81a16d1fc8d4ee.zip stroke-701abcb162dfb3e7cc8c6a9ada81a16d1fc8d4ee.tar.bz2 |
Minor changes to PubSubManagerImpl and StanzaAckRequester.
Small changes to PubSubManagerImpl and StanzaAckRequester making them equivalent with Swiften.
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Test-Information:
Added tests for StanzaAckResponder and StanzaAckRequester, which passes.
Change-Id: I99878fc6552ed18e353848a0cea6584c26b2ba0c
Diffstat (limited to 'src/com/isode')
3 files changed, 28 insertions, 13 deletions
diff --git a/src/com/isode/stroke/pubsub/PubSubManagerImpl.java b/src/com/isode/stroke/pubsub/PubSubManagerImpl.java index ab1e8c6..a8bdafd 100644 --- a/src/com/isode/stroke/pubsub/PubSubManagerImpl.java +++ b/src/com/isode/stroke/pubsub/PubSubManagerImpl.java @@ -14,6 +14,7 @@ import com.isode.stroke.elements.Message; import com.isode.stroke.parser.payloadparsers.PubSubEvent; import com.isode.stroke.queries.IQRouter; import com.isode.stroke.signals.Slot1; +import com.isode.stroke.signals.SignalConnection; public class PubSubManagerImpl extends PubSubManager { @@ -21,16 +22,30 @@ public class PubSubManagerImpl extends PubSubManager { stanzaChannel_ = stanzaChannel; router_ = router; - stanzaChannel.onMessageReceived.connect(new Slot1<Message>() { + onMessageReceivedConnection = stanzaChannel.onMessageReceived.connect(new Slot1<Message>() { public void call(Message message) { - PubSubEvent event = (PubSubEvent)message.getPayload(new PubSubEvent()); - if (event != null) { - onEvent.emit(message.getFrom(), event.getPayload()); - } + handleMessageRecevied(message); } }); } - - StanzaChannel stanzaChannel_; - IQRouter router_; + + protected void finalize() throws Throwable { + try { + onMessageReceivedConnection.disconnect(); + } + finally { + super.finalize(); + } + } + + private void handleMessageRecevied(Message message) { + if (message.getPayload(new PubSubEvent()) != null) { + PubSubEvent event = (PubSubEvent)message.getPayload(new PubSubEvent()); + onEvent.emit(message.getFrom(), event.getPayload()); + } + } + + private SignalConnection onMessageReceivedConnection; + private StanzaChannel stanzaChannel_; + private IQRouter router_; } diff --git a/src/com/isode/stroke/streammanagement/StanzaAckRequester.java b/src/com/isode/stroke/streammanagement/StanzaAckRequester.java index c106851..8ff7dc7 100644 --- a/src/com/isode/stroke/streammanagement/StanzaAckRequester.java +++ b/src/com/isode/stroke/streammanagement/StanzaAckRequester.java @@ -20,7 +20,7 @@ public class StanzaAckRequester { static final long MAX_HANDLED_STANZA_COUNT = Long.parseLong("4294967295"); //boost::numeric_cast<unsigned int>((1ULL<<32) - 1); public StanzaAckRequester() { - + this.lastHandledStanzasCount = 0L; } public void handleStanzaSent(Stanza stanza) { @@ -34,7 +34,7 @@ public class StanzaAckRequester { long i = lastHandledStanzasCount; while (i != handledStanzasCount) { if (unackedStanzas.isEmpty()) { - //std::cerr << "Warning: Server acked more stanzas than we sent" << std::endl; + System.err.println("Warning: Server acked more stanzas than we sent"); break; } Stanza ackedStanza = unackedStanzas.get(0); @@ -49,7 +49,7 @@ public class StanzaAckRequester { public Signal1<Stanza> onStanzaAcked = new Signal1<Stanza>(); - private long lastHandledStanzasCount; + long lastHandledStanzasCount; - private List<Stanza> unackedStanzas = new ArrayList<Stanza>(); + List<Stanza> unackedStanzas = new ArrayList<Stanza>(); } diff --git a/src/com/isode/stroke/streammanagement/StanzaAckResponder.java b/src/com/isode/stroke/streammanagement/StanzaAckResponder.java index 43faca2..7c4fd22 100644 --- a/src/com/isode/stroke/streammanagement/StanzaAckResponder.java +++ b/src/com/isode/stroke/streammanagement/StanzaAckResponder.java @@ -25,5 +25,5 @@ public class StanzaAckResponder { onAck.emit(handledStanzasCount); } public Signal1<Long> onAck = new Signal1<Long>(); - private long handledStanzasCount = 0; + long handledStanzasCount = 0; } |