Added connect method to re-activate client subscription on the tree

This commit is contained in:
selva.andre
2012-09-05 19:32:42 +02:00
parent 59c7a85355
commit fc223d0b0b
@@ -137,6 +137,9 @@ public class SubscriptionsStore {
}
}
/**
* Deactivate all topic subscriptions for the given clientID.
* */
void disconnect(String clientID) {
for (Subscription s : m_subscriptions) {
if (s.clientId.equals(clientID)) {
@@ -149,6 +152,23 @@ public class SubscriptionsStore {
child.disconnect(clientID);
}
}
/**
* Activate all topic subscriptions for the given clientID.
* */
public void connect(String clientID) {
for (Subscription s : m_subscriptions) {
if (s.clientId.equals(clientID)) {
s.setActive(true);
}
}
//go deep
for (TreeNode child : m_children) {
child.disconnect(clientID);
}
}
}
protected static class Token {
@@ -302,6 +322,11 @@ public class SubscriptionsStore {
subscriptions.disconnect(clientID);
}
public void connect(String clientID) {
LOG.debug("connect re-activating subscriptions for clientID " + clientID);
subscriptions.connect(clientID);
}
public List<Subscription> matches(String topic) {
List<Token> tokens = new ArrayList<Token>();
try {