use of org.atmosphere.cpr.BroadcasterFuture in project atmosphere by Atmosphere.
the class ExcludeSessionBroadcaster method broadcast.
/**
* a list of sessions will be exclude for this broadcast
*
* @param msg
* @param sessions
* @return
*/
public Future<Object> broadcast(Object msg, List<HttpSession> sessions) {
if (destroyed.get()) {
return futureDone(msg);
}
Set<AtmosphereResource> subset = new HashSet<AtmosphereResource>();
subset.addAll(resources);
for (AtmosphereResource r : resources) {
if (!r.getAtmosphereResourceEvent().isCancelled() && sessions.contains(r.getRequest().getSession())) {
subset.remove(r);
}
}
start();
Object newMsg = filter(msg);
if (newMsg == null) {
return futureDone(msg);
}
BroadcasterFuture<Object> f = new BroadcasterFuture<Object>(newMsg, subset.size());
dispatchMessages(new Deliver(newMsg, subset, f, msg));
return f;
}
use of org.atmosphere.cpr.BroadcasterFuture in project atmosphere by Atmosphere.
the class SimpleBroadcaster method broadcast.
@Override
public Future<Object> broadcast(Object msg) {
if (destroyed.get()) {
logger.warn("This Broadcaster has been destroyed and cannot be used");
return futureDone(msg);
}
start();
Object newMsg = filter(msg);
if (newMsg == null)
return null;
BroadcasterFuture<Object> f = new BroadcasterFuture<Object>(newMsg);
push(new Deliver(newMsg, f, msg));
return f;
}
Aggregations