public void onSuccess(Void value) { mqtt.tracer.debug("Restoring MQTT connection state"); // Setup a new overflow so that the replay can be sent out before the original overflow list. LinkedList<Request> originalOverflow = overflow; Map<Short, Request> originalRequests = requests; overflow = new LinkedList<Request>(); requests = new ConcurrentHashMap<Short, Request>(); // Restore any active subscriptions. if (!activeSubs.isEmpty()) { ArrayList<Topic> topics = new ArrayList<Topic>(activeSubs.size()); for (Map.Entry<UTF8Buffer, QoS> entry : activeSubs.entrySet()) { topics.add(new Topic(entry.getKey(), entry.getValue())); } send(new SUBSCRIBE().topics(topics.toArray(new Topic[topics.size()])), null); } // Replay any un-acked requests.. for (Map.Entry<Short, Request> entry : originalRequests.entrySet()) { MQTTFrame frame = entry.getValue().frame; frame.dup(true); // set the dup flag as these frames were previously transmitted. send(entry.getValue()); } // Replay the original overflow for (Request request : originalOverflow) { // Stuff in the overflow never got sent out.. so no need to set the dup flag send(request); } }
return "MQTTFrame { type: "+type+", qos: "+qos()+", dup:"+dup()+" }";
public void onSuccess(Void value) { mqtt.tracer.debug("Restoring MQTT connection state"); // Setup a new overflow so that the replay can be sent out before the original overflow list. LinkedList<Request> originalOverflow = overflow; Map<Short, Request> originalRequests = requests; overflow = new LinkedList<Request>(); requests = new ConcurrentHashMap<Short, Request>(); // Restore any active subscriptions. if (!activeSubs.isEmpty()) { ArrayList<Topic> topics = new ArrayList<Topic>(activeSubs.size()); for (Map.Entry<UTF8Buffer, QoS> entry : activeSubs.entrySet()) { topics.add(new Topic(entry.getKey(), entry.getValue())); } send(new SUBSCRIBE().topics(topics.toArray(new Topic[topics.size()])), null); } // Replay any un-acked requests.. for (Map.Entry<Short, Request> entry : originalRequests.entrySet()) { MQTTFrame frame = entry.getValue().frame; frame.dup(true); // set the dup flag as these frames were previously transmitted. send(entry.getValue()); } // Replay the original overflow for (Request request : originalOverflow) { // Stuff in the overflow never got sent out.. so no need to set the dup flag send(request); } }
return "MQTTFrame { type: "+type+", qos: "+qos()+", dup:"+dup()+" }";