|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.atmosphere.cpr.DefaultBroadcaster
public class DefaultBroadcaster
Broadcaster implementation.
Broadcast messages to suspended response using the caller's Thread.
This basic Broadcaster use an ExecutorService
to broadcast message, hence the broadcast operation is asynchronous. Make sure
you block on broadcast(Object).get()} if you need synchronous operations.
| Nested Class Summary | |
|---|---|
class |
DefaultBroadcaster.Entry
|
| Nested classes/interfaces inherited from interface org.atmosphere.cpr.Broadcaster |
|---|
Broadcaster.SCOPE |
| Field Summary | |
|---|---|
protected BroadcasterConfig |
bc
|
protected ConcurrentLinkedQueue<DefaultBroadcaster.Entry> |
delayedBroadcast
|
protected ConcurrentLinkedQueue<AtmosphereResource> |
events
|
protected BlockingQueue<DefaultBroadcaster.Entry> |
messages
|
protected String |
name
|
protected Broadcaster.SCOPE |
scope
|
protected AtomicBoolean |
started
|
| Constructor Summary | |
|---|---|
DefaultBroadcaster()
|
|
DefaultBroadcaster(BroadcasterConfig bc)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final ConcurrentLinkedQueue<AtmosphereResource> events
protected BroadcasterConfig bc
protected final BlockingQueue<DefaultBroadcaster.Entry> messages
protected final AtomicBoolean started
protected Broadcaster.SCOPE scope
protected String name
protected final ConcurrentLinkedQueue<DefaultBroadcaster.Entry> delayedBroadcast
| Constructor Detail |
|---|
public DefaultBroadcaster()
public DefaultBroadcaster(BroadcasterConfig bc)
| Method Detail |
|---|
public void destroy()
ExecutorService
destroy in interface Broadcasterpublic Iterator<AtmosphereResource> getAtmosphereResources()
Iterator of AtmosphereResource.
getAtmosphereResources in interface BroadcasterIterator of AtmosphereResource associated with this Broadcaster.Broadcaster.addAtmosphereResource(AtmosphereResource)public void setScope(Broadcaster.SCOPE scope)
setScope in interface Broadcasterscope - Broadcaster.SCOPE to set.public Broadcaster.SCOPE getScope()
Broadcaster.SCOPE
getScope in interface BroadcasterBroadcaster.SCOPE of Broadcaster.public void setID(String id)
Broadcaster
setID in interface Broadcasterid - ID of this Broadcasterpublic String getID()
Broadcaster
getID in interface BroadcasterBroadcasterpublic void resumeAll()
AtmosphereResource) added via
Broadcaster.addAtmosphereResource(org.atmosphere.cpr.AtmosphereResource).
resumeAll in interface Broadcasterprotected void start()
protected void push(DefaultBroadcaster.Entry msg)
protected void broadcast(AtmosphereResource r,
AtmosphereResourceEvent e)
protected void onException(Throwable t,
AtmosphereResource r)
public BroadcasterFuture<Object> broadcast(Object msg)
Object to all suspended response, e.g. invoke
AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) .
broadcast in interface Broadcastermsg - and Object to be broadcasted.
Future that can be used to synchronize using the Future.get()protected Object filter(Object msg)
BroadcastFilter
msg -
public BroadcasterFuture<Object> broadcast(Object msg,
AtmosphereResource r)
Object to all suspended response, e.g. invoke
AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) with an instance of AtmosphereResource, representing
a single suspended response..
broadcast in interface Broadcastermsg - and Object to be broadcasted.r - an AtmosphereResource
Future that can be used to synchronize using the Future.get()
public BroadcasterFuture<Object> broadcast(Object msg,
Set<AtmosphereResource> subset)
Object to all suspended response, e.g. invoke
AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) with a Set of AtmosphereResource,
representing a set of AtmosphereHandler.
broadcast in interface Broadcastermsg - and Object to be broadcasted.subset - a Set of AtmosphereResource
Future that can be used to synchronize using the Future.get()public AtmosphereResource addAtmosphereResource(AtmosphereResource r)
AtmosphereResource to the list of item to be notified when
the Broadcaster.broadcast(java.lang.Object) is invoked.
addAtmosphereResource in interface Broadcasterr - an AtmosphereResource
AtmosphereResource if added, or null if it was already there.public AtmosphereResource removeAtmosphereResource(AtmosphereResource r)
AtmosphereResource from the list of item to be notified when
the Broadcaster.broadcast(java.lang.Object) is invoked.
removeAtmosphereResource in interface Broadcasterr - an AtmosphereResource
AtmosphereResource if removed, or null if it was not.protected ConcurrentLinkedQueue<AtmosphereResource> atmosphereResources()
public void setBroadcasterConfig(BroadcasterConfig bc)
BroadcasterConfig instance.
setBroadcasterConfig in interface Broadcasterbc - public BroadcasterConfig getBroadcasterConfig()
BroadcasterConfig
getBroadcasterConfig in interface BroadcasterBroadcasterConfigpublic Future<Object> delayBroadcast(Object o)
Object will be broadcasted
when the first Broadcaster.broadcast(java.lang.Object)
is invoked.
delayBroadcast in interface Broadcastero - and Object to be broadcasted.
Future that can be used to synchronize using the Future.get()
public Future<Object> delayBroadcast(Object o,
long delay,
TimeUnit t)
Object will be broadcasted once the
specified delay expires or when the first Broadcaster.broadcast(java.lang.Object)
delayBroadcast in interface Broadcastero - and Object to be broadcasted.delay - Amount of time to delay.t - a TimeUnit of delay.
Future that can be used to synchronize using the Future.get()
public Future<?> scheduleFixedBroadcast(Object o,
long period,
TimeUnit t)
Object will be broadcasted after every period
specified time frame expires. If the TimeUnit is set null, the
Object will be broadcasted when the first Broadcaster.broadcast(java.lang.Object)
is invoked.
scheduleFixedBroadcast in interface Broadcastero - and Object to be broadcasted.period - Every so often broadcast.t - a TimeUnit of period.
Future that can be used to synchronize using the Future.get()
public Future<?> scheduleFixedBroadcast(Object o,
long waitFor,
long period,
TimeUnit t)
Object will be broadcasted after every period
specified time frame expires. If the TimeUnit is set null, the * Object will be broadcasted when the first Broadcaster.broadcast(java.lang.Object) * is invoked.
scheduleFixedBroadcast in interface Broadcastero - and Object to be broadcasted.waitFor - Wait for that long before first broadcast.period - The period inbetween broadcast.t - a TimeUnit of waitFor and period.
Future that can be used to synchronize using the Future.get()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||