summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/isode/stroke/pubsub/PubSubManagerImpl.java31
-rw-r--r--src/com/isode/stroke/streammanagement/StanzaAckRequester.java8
-rw-r--r--src/com/isode/stroke/streammanagement/StanzaAckResponder.java2
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;
}