use of org.atmosphere.cpr.BroadcasterFuture in project atmosphere by Atmosphere.
the class ExcludeSessionBroadcaster method broadcast.
/**
* the AtmosphereResources subset will be exclude for this broadcast
*
* @param msg
* @param subset
* @return
*/
@Override
public Future<Object> broadcast(Object msg, Set<AtmosphereResource> subset) {
if (destroyed.get()) {
return futureDone(msg);
}
subset.retainAll(resources);
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 ExcludeSessionBroadcaster method broadcast.
/**
* session will be exclude for this broadcast
*
* @param msg
* @param s
* @return
*/
public Future<Object> broadcast(Object msg, HttpSession s) {
if (destroyed.get()) {
return futureDone(msg);
}
Set<AtmosphereResource> subset = new HashSet<AtmosphereResource>();
subset.addAll(resources);
for (AtmosphereResource r : resources) {
if (!r.getAtmosphereResourceEvent().isCancelled() && s.equals(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 ExcludeSessionBroadcaster method broadcast.
/**
* the AtmosphereResource r will be exclude for this broadcast
*
* @param msg
* @param r
* @return
*/
@Override
public Future<Object> broadcast(Object msg, AtmosphereResource r) {
if (destroyed.get()) {
throw new IllegalStateException("This Broadcaster has been destroyed and cannot be used");
}
Set<AtmosphereResource> sub = new HashSet<AtmosphereResource>();
sub.addAll(resources);
sub.remove(r);
start();
Object newMsg = filter(msg);
if (newMsg == null) {
return null;
}
BroadcasterFuture<Object> f = new BroadcasterFuture<Object>(newMsg, sub.size());
dispatchMessages(new Deliver(newMsg, sub, 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, AtmosphereResource r) {
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, r, 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, Set<AtmosphereResource> subset) {
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, subset, f, msg));
return f;
}
Aggregations