|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Broadcaster
A Broadcaster is responsible for delivering messages to its subscribed
AtmosphereResource, which are representing a suspended response.
AtmosphereResource can be added using addAtmosphereResource(org.atmosphere.cpr.AtmosphereResource),
so when broadcast(java.lang.Object) execute,
AtmosphereHandler#onStateChange(org.atmosphere.cpr.AtmosphereResource) will
by invoked and the suspended connection will have a chance to write the
message available using AtmosphereResource#getMessage()
A Broadcaster, by default, will use an ExecutorService, and the
number of Thread will be computed based on the core/cpu of the OS under
which the application run.
One final word on Broadcaster: by default, a Broadcaster will broadcast using
all AtmosphereResource on which the response has been suspended, e.g. {AtmosphereResource#suspend()}
has been invoked. This behavior is configurable and you can configure it by invoking the
Broadcaster#setScope()):
| Nested Class Summary | |
|---|---|
static class |
Broadcaster.SCOPE
|
| Method Summary | |
|---|---|
AtmosphereResource |
addAtmosphereResource(AtmosphereResource resource)
Add a AtmosphereResource to the list of item to be notified when
the broadcast(java.lang.Object) is invoked. |
Future<Object> |
broadcast(Object o)
Broadcast the Object to all suspended response, e.g. |
Future<Object> |
broadcast(Object o,
AtmosphereResource resource)
Broadcast the Object to all suspended response, e.g. |
Future<Object> |
broadcast(Object o,
Set<AtmosphereResource> subset)
Broadcast the Object to all suspended response, e.g. |
Future<Object> |
delayBroadcast(Object o)
Delay the broadcast operation. |
Future<Object> |
delayBroadcast(Object o,
long delay,
TimeUnit t)
Delay the broadcast operation. |
void |
destroy()
Destroy this instance and shutdown it's associated ExecutorServices |
Iterator<AtmosphereResource> |
getAtmosphereResources()
Return an Iterator AtmosphereResource |
BroadcasterConfig |
getBroadcasterConfig()
Return the current BroadcasterConfig |
String |
getName()
Return the name of this Broadcaster |
Broadcaster.SCOPE |
getScope()
Retunr the Broadcaster#SCOPE |
AtmosphereResource |
removeAtmosphereResource(AtmosphereResource resource)
Remove a AtmosphereResource from the list of item to be notified when
the broadcast(java.lang.Object) is invoked. |
Future<?> |
scheduleFixedBroadcast(Object o,
long period,
TimeUnit t)
Broadcast periodically. |
void |
setBroadcasterConfig(BroadcasterConfig bc)
Set the BroadcasterConfig instance. |
void |
setName(String name)
Set the name of this Broadcaster |
void |
setScope(Broadcaster.SCOPE scope)
Set the scope. |
| Method Detail |
|---|
Future<Object> broadcast(Object o)
Object to all suspended response, e.g. invoke
AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) .
o - and Object to be broadcasted.
Future that can be used to synchronize using the Future.get()Future<Object> delayBroadcast(Object o)
Object will be broadcasted
when the first broadcast(java.lang.Object)
is invoked.
o - and Object to be broadcasted.
Future that can be used to synchronize using the Future.get()
Future<Object> delayBroadcast(Object o,
long delay,
TimeUnit t)
Object will be broadcasted once the
specified delay expires. If the TimeUnit is set null, the
Object will be broadcasted when the first broadcast(java.lang.Object)
is invoked.
o - and Object to be broadcasted.the - delayt - a TimeUnit
Future that can be used to synchronize using the Future.get()
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 broadcast(java.lang.Object)
is invoked.
o - and Object to be broadcasted.the - periodt - a TimeUnit
Future that can be used to synchronize using the Future.get()
Future<Object> broadcast(Object o,
AtmosphereResource resource)
Object to all suspended response, e.g. invoke
AtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) with an instance of AtmosphereResource, representing
a single suspended response..
o - and Object to be broadcasted.resource - an AtmosphereResource
Future that can be used to synchronize using the Future.get()
Future<Object> broadcast(Object o,
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.
o - and Object to be broadcasted.resource - an AtmosphereResource
Future that can be used to synchronize using the Future.get()AtmosphereResource addAtmosphereResource(AtmosphereResource resource)
AtmosphereResource to the list of item to be notified when
the broadcast(java.lang.Object) is invoked.
resource - an AtmosphereResource
AtmosphereResource if added, or null if it was already there.AtmosphereResource removeAtmosphereResource(AtmosphereResource resource)
AtmosphereResource from the list of item to be notified when
the broadcast(java.lang.Object) is invoked.
resource - an AtmosphereResource
AtmosphereResource if removed, or null if it was not.void setBroadcasterConfig(BroadcasterConfig bc)
BroadcasterConfig instance.
bf - BroadcasterConfig getBroadcasterConfig()
BroadcasterConfig
BroadcasterConfigvoid destroy()
ExecutorServices
Iterator<AtmosphereResource> getAtmosphereResources()
AtmosphereResource
void setScope(Broadcaster.SCOPE scope)
Broadcaster.SCOPE getScope()
Broadcaster#SCOPE
Broadcaster#SCOPEvoid setName(String name)
Broadcaster
name - of this BroadcasterString getName()
Broadcaster
Broadcaster
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||