public class DefaultRemoteEventService extends RemoteEventServiceAccessor implements RemoteEventService
RemoteEventListener
).
It keeps a connection to the server. When an event occurred at the server, the RemoteEventService informs the RemoteEventListeners
about the event and starts listening at the server again. When no RemoteEventListeners registered anymore, the
RemoteEventService stops listening till new RemoteEventListeners are registered.
The listening works with a domain/context scope. See the documentation/manual to get more information about the
listening concept.RemoteEventServiceAccessor.VoidAsyncCallback
Modifier | Constructor and Description |
---|---|
protected |
DefaultRemoteEventService(RemoteEventConnector aRemoteEventConnector)
Creates a new RemoteEventService.
|
Modifier and Type | Method and Description |
---|---|
void |
addEvent(Domain aDomain,
Event anEvent)
Adds / sends an event to a domain.
|
void |
addEvent(Domain aDomain,
Event anEvent,
AsyncCallback<Void> aCallback)
Adds / sends an event to a domain.
|
void |
addListener(Domain aDomain,
RemoteEventListener aRemoteListener)
Adds a listener for a domain.
|
void |
addListener(Domain aDomain,
RemoteEventListener aRemoteListener,
AsyncCallback<Void> aCallback)
Adds a listener for a domain.
|
void |
addListener(Domain aDomain,
RemoteEventListener aRemoteListener,
EventFilter anEventFilter)
Adds a listener for a domain.
|
void |
addListener(Domain aDomain,
RemoteEventListener aRemoteListener,
EventFilter anEventFilter,
AsyncCallback<Void> aCallback)
Adds a listener for a domain.
|
void |
addUnlistenListener(UnlistenEventListener.Scope anUnlistenScope,
UnlistenEventListener anUnlistenEventListener,
AsyncCallback<Void> aCallback)
Registers an
UnlistenEventListener to listen for all
user/client domain deregistrations and timeouts. |
void |
addUnlistenListener(UnlistenEventListener.Scope anUnlistenScope,
UnlistenEventListener anUnlistenEventListener,
UnlistenEvent anUnlistenEvent,
AsyncCallback<Void> aCallback)
Registers an
UnlistenEventListener to listen for all
user/client domain deregistrations and timeouts. |
void |
addUnlistenListener(UnlistenEventListener anUnlistenEventListener,
AsyncCallback<Void> aCallback)
Registers an
UnlistenEventListener to listen for all
user/client domain deregistrations and timeouts. |
void |
addUnlistenListener(UnlistenEventListener anUnlistenEventListener,
UnlistenEvent anUnlistenEvent,
AsyncCallback<Void> aCallback)
Registers an
UnlistenEventListener to listen for all
user/client domain deregistrations and timeouts. |
void |
deregisterEventFilter(Domain aDomain)
Deregisters the EventFilter for a domain.
|
void |
deregisterEventFilter(Domain aDomain,
AsyncCallback<Void> aCallback)
Deregisters the EventFilter for a domain.
|
Set<Domain> |
getActiveDomains()
Returns all active domains (all domains where the client has listeners registered).
|
List<RemoteEventListener> |
getRegisteredListeners(Domain aDomain)
Returns all registered listeners of a domain.
|
boolean |
isActive()
Checks if the RemoteEventService is active (listening).
|
void |
registerEventFilter(Domain aDomain,
EventFilter anEventFilter)
Registers an EventFilter for a domain.
|
void |
registerEventFilter(Domain aDomain,
EventFilter anEventFilter,
AsyncCallback<Void> aCallback)
Registers an EventFilter for a domain.
|
void |
removeListener(Domain aDomain,
RemoteEventListener aRemoteListener)
Removes a listener for a domain.
|
void |
removeListener(Domain aDomain,
RemoteEventListener aRemoteListener,
AsyncCallback<Void> aCallback)
Removes a listener for a domain.
|
void |
removeListeners()
Removes all RemoteEventListeners and deactivates the RemoteEventService (stop listening).
|
void |
removeListeners(AsyncCallback<Void> aCallback)
Removes all RemoteEventListeners and deactivates the RemoteEventService (stop listening).
|
void |
removeListeners(Domain aDomain)
Stops listening for the corresponding domain.
|
void |
removeListeners(Domain aDomain,
AsyncCallback<Void> aCallback)
Stops listening for the corresponding domain.
|
void |
removeListeners(Set<Domain> aDomains)
Calls unlisten for a set of domains (stop listening for these domains).
|
void |
removeListeners(Set<Domain> aDomains,
AsyncCallback<Void> aCallback)
Calls unlisten for a set of domains (stop listening for these domains).
|
void |
removeUnlistenListener(UnlistenEventListener anUnlistenEventListener,
AsyncCallback<Void> aCallback)
Removes an
UnlistenEventListener . |
void |
removeUnlistenListeners(AsyncCallback<Void> aCallback)
Stops listening for
UnlistenEvent instances. |
getRemoteEventConnector, isListenActive, reset, schedule
protected DefaultRemoteEventService(RemoteEventConnector aRemoteEventConnector)
aRemoteEventConnector
- RemoteEventConnector
for the connection
between client side and server sidepublic void addListener(Domain aDomain, RemoteEventListener aRemoteListener)
addListener
in interface RemoteEventService
aDomain
- domainaRemoteListener
- new listenerpublic void addListener(Domain aDomain, RemoteEventListener aRemoteListener, AsyncCallback<Void> aCallback)
addListener
in interface RemoteEventService
aDomain
- domainaRemoteListener
- new listeneraCallback
- callback (only called when no listener is already registered for the domain)public void addListener(Domain aDomain, RemoteEventListener aRemoteListener, EventFilter anEventFilter)
addListener
in interface RemoteEventService
aDomain
- domainaRemoteListener
- new listeneranEventFilter
- EventFilter to filter the events before RemoteEventListenerpublic void addListener(Domain aDomain, RemoteEventListener aRemoteListener, EventFilter anEventFilter, AsyncCallback<Void> aCallback)
addListener
in interface RemoteEventService
aDomain
- domainaRemoteListener
- new listeneranEventFilter
- EventFilter to filter the events before RemoteEventListeneraCallback
- callback (only called when no listener is registered for the domain)public void addUnlistenListener(UnlistenEventListener anUnlistenEventListener, AsyncCallback<Void> aCallback)
UnlistenEventListener
to listen for all
user/client domain deregistrations and timeouts. The scope for unlisten events to receive is set to
UnlistenEventListener.Scope.UNLISTEN
by default.
To use other scopes see
RemoteEventService.addUnlistenListener(de.novanic.eventservice.client.event.listener.unlisten.UnlistenEventListener.Scope, de.novanic.eventservice.client.event.listener.unlisten.UnlistenEventListener, com.google.gwt.user.client.rpc.AsyncCallback)
.addUnlistenListener
in interface RemoteEventService
anUnlistenEventListener
- UnlistenEventListener
to listen for all user/client domain deregistrations and timeouts.aCallback
- callbackpublic void addUnlistenListener(UnlistenEventListener.Scope anUnlistenScope, UnlistenEventListener anUnlistenEventListener, AsyncCallback<Void> aCallback)
UnlistenEventListener
to listen for all
user/client domain deregistrations and timeouts.addUnlistenListener
in interface RemoteEventService
anUnlistenEventListener
- UnlistenEventListener
to listen for all user/client domain deregistrations and timeouts.anUnlistenScope
- scope of the unlisten events to receiveaCallback
- callbackpublic void addUnlistenListener(UnlistenEventListener anUnlistenEventListener, UnlistenEvent anUnlistenEvent, AsyncCallback<Void> aCallback)
UnlistenEventListener
to listen for all
user/client domain deregistrations and timeouts. The custom UnlistenEvent
will be registered at the server side and transferred to all users/clients which have an UnlistenEventListener
registered. That UnlistenEvent
can for example contain user information
of your specific user-system to recover the user in your user-system on a timeout. The scope for unlisten events to receive is set to
UnlistenEventListener.Scope.UNLISTEN
by default.
To use other scopes see
RemoteEventService.addUnlistenListener(de.novanic.eventservice.client.event.listener.unlisten.UnlistenEventListener.Scope, de.novanic.eventservice.client.event.listener.unlisten.UnlistenEventListener, de.novanic.eventservice.client.event.listener.unlisten.UnlistenEvent, com.google.gwt.user.client.rpc.AsyncCallback)
.addUnlistenListener
in interface RemoteEventService
anUnlistenEventListener
- UnlistenEventListener
to listen for all user/client domain deregistrations and timeouts.anUnlistenEvent
- UnlistenEvent
which can contain custom dataaCallback
- callbackpublic void addUnlistenListener(UnlistenEventListener.Scope anUnlistenScope, UnlistenEventListener anUnlistenEventListener, UnlistenEvent anUnlistenEvent, AsyncCallback<Void> aCallback)
UnlistenEventListener
to listen for all
user/client domain deregistrations and timeouts. The custom UnlistenEvent
will be registered at the server side and transferred to all users/clients which have an UnlistenEventListener
registered. That UnlistenEvent
can for example contain user information
of your specific user-system to recover the user in your user-system on a timeout.addUnlistenListener
in interface RemoteEventService
anUnlistenScope
- scope of the unlisten events to receiveanUnlistenEventListener
- UnlistenEventListener
to listen for all user/client domain deregistrations and timeouts.anUnlistenEvent
- UnlistenEvent
which can contain custom dataaCallback
- callbackpublic void removeListener(Domain aDomain, RemoteEventListener aRemoteListener)
removeListener
in interface RemoteEventService
aDomain
- domainaRemoteListener
- listener to removepublic void removeListener(Domain aDomain, RemoteEventListener aRemoteListener, AsyncCallback<Void> aCallback)
removeListener
in interface RemoteEventService
aDomain
- domain to remove the listener from (the domain will be removed when no other listeners are registered to the domain)aRemoteListener
- listener to removeaCallback
- callbackpublic void registerEventFilter(Domain aDomain, EventFilter anEventFilter)
registerEventFilter
in interface RemoteEventService
aDomain
- domainanEventFilter
- EventFilter to filter the events before RemoteEventListenerpublic void registerEventFilter(Domain aDomain, EventFilter anEventFilter, AsyncCallback<Void> aCallback)
registerEventFilter
in interface RemoteEventService
aDomain
- domainanEventFilter
- EventFilter to filter the events before RemoteEventListeneraCallback
- callbackpublic void deregisterEventFilter(Domain aDomain)
deregisterEventFilter
in interface RemoteEventService
aDomain
- domain to remove the EventFilter frompublic void deregisterEventFilter(Domain aDomain, AsyncCallback<Void> aCallback)
deregisterEventFilter
in interface RemoteEventService
aDomain
- domain to remove the EventFilter fromaCallback
- callbackpublic boolean isActive()
isActive
in interface RemoteEventService
public Set<Domain> getActiveDomains()
getActiveDomains
in interface RemoteEventService
public List<RemoteEventListener> getRegisteredListeners(Domain aDomain)
getRegisteredListeners
in interface RemoteEventService
aDomain
- domainpublic void removeListeners()
removeListeners
in interface RemoteEventService
public void removeListeners(AsyncCallback<Void> aCallback)
removeListeners
in interface RemoteEventService
aCallback
- callback (only called when a listener is registered for the domain)public void removeListeners(Set<Domain> aDomains)
removeListeners()
can be used to call unlisten for all domains.removeListeners
in interface RemoteEventService
aDomains
- domains to unlistenpublic void removeListeners(Set<Domain> aDomains, AsyncCallback<Void> aCallback)
removeListeners()
can be used to call unlisten for all domains.removeListeners
in interface RemoteEventService
aDomains
- domains to unlistenaCallback
- callback (only called when a listener is registered for the domain)public void removeListeners(Domain aDomain)
removeListeners()
can be used to call unlisten for all domains.removeListeners
in interface RemoteEventService
aDomain
- domain to unlistenpublic void removeListeners(Domain aDomain, AsyncCallback<Void> aCallback)
removeListeners()
can be used to call unlisten for all domains.removeListeners
in interface RemoteEventService
aDomain
- domain to unlistenaCallback
- callback (only called when a listener is registered for the domain)public void removeUnlistenListener(UnlistenEventListener anUnlistenEventListener, AsyncCallback<Void> aCallback)
UnlistenEventListener
.
The RemoteEventService will get inactive, when no other listeners are registered.removeUnlistenListener
in interface RemoteEventService
anUnlistenEventListener
- UnlistenEventListener
to removeaCallback
- callbackpublic void removeUnlistenListeners(AsyncCallback<Void> aCallback)
UnlistenEvent
instances.removeUnlistenListeners
in interface RemoteEventService
aCallback
- callback (only called when an UnlistenEventListener
is registered)public void addEvent(Domain aDomain, Event anEvent)
DomainFactory.USER_SPECIFIC_DOMAIN
.addEvent
in interface RemoteEventService
aDomain
- domainanEvent
- eventpublic void addEvent(Domain aDomain, Event anEvent, AsyncCallback<Void> aCallback)
DomainFactory.USER_SPECIFIC_DOMAIN
.addEvent
in interface RemoteEventService
aDomain
- domainanEvent
- eventaCallback
- callbackCopyright © 2012. All Rights Reserved.