Skip to content

Commit

Permalink
Fixes #1342
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Oct 15, 2013
1 parent ebbaa7e commit fae5113
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,26 @@ public void onAddAtmosphereResource(Broadcaster b, AtmosphereResource r) {
if (t == null) {
t = track(r);
}
logger.trace("Starting tracking the state of {} with broadcaster {}", r.uuid(), b.getID());
t.add(b);
}

@Override
public void onRemoveAtmosphereResource(Broadcaster b, AtmosphereResource r) {
// We track cancelled and resumed connection only.
BroadcasterTracker t = states.get(r.uuid());

// The BroadcasterTracker was swapped
if (t == null) {
onAddAtmosphereResource(b, r);
}

AtmosphereResourceEvent e = r.getAtmosphereResourceEvent();
if (t != null && (e.isClosedByClient() || !r.isResumed() && !e.isResumedOnTimeout())) {
t.remove(b);
} else {
logger.trace("Keeping the state of {} with broadcaster {}", r.uuid(), b.getID());
logger.trace("State for {} with broadcaster {}", r.uuid(), t != null ? t.ids() : "null");
}
}
}
Expand Down

0 comments on commit fae5113

Please sign in to comment.