public class EventBus extends Object implements ISessionStore.UnboundListener
Subscribe
.
Posted events are broadcasted to all components on active
pages if they have a method annotated with Subscribe
. To create and register an
EventBus
, put the following code in your application's init method:
this.eventBus = new EventBus(this);The
EventBus
will register itself in the application once instantiated. It might be
practical to keep a reference in the application, but you can always get it using get()
.Constructor and Description |
---|
EventBus(WebApplication application)
Creates and registers an
EventBus for the given application. |
EventBus(WebApplication application,
org.atmosphere.cpr.Broadcaster broadcaster)
Creates and registers an
EventBus for the given application and broadcaster |
Modifier and Type | Method and Description |
---|---|
void |
addRegistrationListener(ResourceRegistrationListener listener)
Add a new
ResourceRegistrationListener to the EventBus . |
protected IComponentOnBeforeRenderListener |
createEventSubscriptionCollector() |
protected EventSubscriptionInvoker |
createEventSubscriptionInvoker() |
static EventBus |
get() |
static EventBus |
get(Application application) |
org.atmosphere.cpr.Broadcaster |
getBroadcaster() |
AtmosphereParameters |
getParameters()
Returns the parameters that will be passed to the
Atmosphere JQuery plugin.
|
static boolean |
isInstalled(Application application) |
boolean |
isWantAtmosphereNotifications() |
void |
post(Object event)
Post an event to all pages that have a suspended connection.
|
void |
post(Object event,
org.atmosphere.cpr.AtmosphereResource resource)
Post an event to a single resource.
|
void |
post(Object event,
String resourceUuid)
Post an event to a single resource.
|
void |
register(Page page,
EventSubscription subscription)
Registers an
EventSubscription for the given page. |
void |
registerPage(String trackingId,
Page page)
Registers a page for the given tracking-id in the
EventBus . |
void |
removeRegistrationListener(ResourceRegistrationListener listener)
Removes a previously added
ResourceRegistrationListener . |
void |
sessionUnbound(String sessionId)
Informs the listener that session with specific id has been unbound.
|
EventBus |
setBroadcaster(org.atmosphere.cpr.Broadcaster broadcaster) |
EventBus |
setWantAtmosphereNotifications(boolean wantAtmosphereNotifications)
A flag indicating whether to be notified about Atmosphere internal events
Caution:: enabling this may cause a lot of onBroadcast notifications
|
void |
unregister(Component component)
Unregisters all
EventSubscription s for the given component, including the
subscriptions for its behaviors. |
void |
unregister(Page page,
EventSubscription subscription)
Unregisters an
EventSubscription for the given page. |
void |
unregister(PageKey pageKey)
Unregisters all
EventSubscription s for the given pageKey. |
void |
unregisterConnection(String trackingId)
Unregisters all subscriptions for the given tracking id.
|
public EventBus(WebApplication application)
EventBus
for the given application. The first broadcaster
returned by the BroadcasterFactory
is used.application
- public EventBus(WebApplication application, org.atmosphere.cpr.Broadcaster broadcaster)
EventBus
for the given application and broadcasterapplication
- broadcaster
- public static EventBus get()
EventBus
registered for the current Wicket application.public static EventBus get(Application application)
application
- EventBus
registered for the given Wicket application.public static boolean isInstalled(Application application)
application
- true
if there is an installed EventBus to the given applicationprotected EventSubscriptionInvoker createEventSubscriptionInvoker()
protected IComponentOnBeforeRenderListener createEventSubscriptionCollector()
public org.atmosphere.cpr.Broadcaster getBroadcaster()
Broadcaster
used by the EventBus
to broadcast messages to.public EventBus setBroadcaster(org.atmosphere.cpr.Broadcaster broadcaster)
public AtmosphereParameters getParameters()
public void registerPage(String trackingId, Page page)
EventBus
.trackingId
- page
- public void register(Page page, EventSubscription subscription)
EventSubscription
for the given page.page
- subscription
- public void unregister(Page page, EventSubscription subscription)
EventSubscription
for the given page.page
- subscription
- public void unregister(PageKey pageKey)
EventSubscription
s for the given pageKey.pageKey
- The key with the page id and session idpublic void unregister(Component component)
EventSubscription
s for the given component, including the
subscriptions for its behaviors.component
- public void unregisterConnection(String trackingId)
trackingId
- public void post(Object event, String resourceUuid)
AtmosphereBehavior.getUUID(Page)
. If no resource
exists with the given UUID, no post is performed.event
- resourceUuid
- public void post(Object event, org.atmosphere.cpr.AtmosphereResource resource)
event
- resource
- public void post(Object event)
Subscribe
. The resulting AJAX updates are
pushed to the clients.event
- public void sessionUnbound(String sessionId)
ISessionStore.UnboundListener
sessionUnbound
in interface ISessionStore.UnboundListener
public void addRegistrationListener(ResourceRegistrationListener listener)
ResourceRegistrationListener
to the EventBus
. This listener will be
notified on all Atmosphere resource registrations and unregistrations.listener
- public void removeRegistrationListener(ResourceRegistrationListener listener)
ResourceRegistrationListener
.listener
- public boolean isWantAtmosphereNotifications()
AtmosphereInternalEvent
,
AtmosphereResourceEventListener
public EventBus setWantAtmosphereNotifications(boolean wantAtmosphereNotifications)
wantAtmosphereNotifications
- true
to be notified, false
- otherwiseAtmosphereInternalEvent
,
AtmosphereResourceEventListener
Copyright © 2006–2021 Apache Software Foundation. All rights reserved.