public interface MetaBroadcaster extends AtmosphereConfigAware
Broadcasters based on their Broadcaster.getID() value.
This class allows broadcasting events to a set of broadcasters that maps to some String like:
// Broadcast the event to all Broadcaster ID starting with /hello
broadcast("/hello", event)
// Broadcast the event to all Broadcaster ID
broaccast("/*", event);
The rule used is similar to path/URI mapping used by technology like Servlet, Jersey, etc.
NOTE: Broadcasters' name must start with / in order to get retrieved by this class.
This class is NOT thread safe.
If you want to use MetaBroadcaster with Jersey or any framework, make sure all Broadcaster.getID()
starts with '/'. For example, with Jersey:
| Modifier and Type | Interface and Description |
|---|---|
static interface |
MetaBroadcaster.MetaBroadcasterCache
Cache message if no
Broadcaster maps the broadcastTo(String, Object) |
static class |
MetaBroadcaster.NoCache |
static class |
MetaBroadcaster.ThirtySecondsCache
Flush the cache every 30 seconds.
|
| Modifier and Type | Method and Description |
|---|---|
MetaBroadcaster |
addBroadcasterListener(BroadcasterListener b)
Add a
BroadcasterListener to all mapped Broadcasters. |
Future<List<Broadcaster>> |
broadcastTo(String broadcasterID,
Object message)
Broadcast the message to all Broadcasters whose
Broadcaster.getID() matches the broadcasterID value. |
Future<List<Broadcaster>> |
broadcastTo(String broadcasterID,
Object message,
boolean cacheMessage)
Broadcast the message to all Broadcasters whose
Broadcaster.getID() matches the broadcasterID value. |
MetaBroadcaster |
cache(MetaBroadcaster.MetaBroadcasterCache cache)
Set the
MetaBroadcaster.MetaBroadcasterCache. |
Future<List<Broadcaster>> |
delayTo(String broadcasterID,
Object message,
int time,
TimeUnit unit)
Delay the message delivery to Broadcasters whose
Broadcaster.getID()
matches the broadcasterID value. |
void |
destroy() |
MetaBroadcaster |
removeBroadcasterListener(BroadcasterListener b)
Remove the
BroadcasterListener. |
Future<List<Broadcaster>> |
scheduleTo(String broadcasterID,
Object message,
int time,
TimeUnit unit)
Broadcast the message at a fixed rate to all Broadcasters whose
Broadcaster.getID()
matches the broadcasterID value. |
configureFuture<List<Broadcaster>> broadcastTo(String broadcasterID, Object message)
Broadcaster.getID() matches the broadcasterID value.broadcasterID - a String (or path) that can potentially match a Broadcaster.getID()message - a message to be broadcastedFuture<List<Broadcaster>> broadcastTo(String broadcasterID, Object message, boolean cacheMessage)
Broadcaster.getID() matches the broadcasterID value.broadcasterID - a String (or path) that can potentially match a Broadcaster.getID()message - a message to be broadcastedcacheMessage - allow the cache to be cached or not.Future<List<Broadcaster>> scheduleTo(String broadcasterID, Object message, int time, TimeUnit unit)
Broadcaster.getID()
matches the broadcasterID value. This operation will invoke Broadcaster.scheduleFixedBroadcast(Object, long, java.util.concurrent.TimeUnit)}broadcasterID - a String (or path) that can potentially match a Broadcaster.getID()message - a message to be broadcastedtime - a time valueunit - a TimeUnitFuture<List<Broadcaster>> delayTo(String broadcasterID, Object message, int time, TimeUnit unit)
Broadcaster.getID()
matches the broadcasterID value. This operation will invoke Broadcaster.delayBroadcast(Object, long, java.util.concurrent.TimeUnit) (Object, long, java.util.concurrent.TimeUnit)}}broadcasterID - a String (or path) that can potentially match a Broadcaster.getID()message - a message to be broadcastedtime - a time valueunit - a TimeUnitMetaBroadcaster addBroadcasterListener(BroadcasterListener b)
BroadcasterListener to all mapped Broadcasters.b - BroadcasterListenerMetaBroadcaster removeBroadcasterListener(BroadcasterListener b)
BroadcasterListener.b - BroadcasterListenerMetaBroadcaster cache(MetaBroadcaster.MetaBroadcasterCache cache)
MetaBroadcaster.MetaBroadcasterCache. Default is MetaBroadcaster.NoCache.cache - void destroy()
Copyright © 2016. All rights reserved.