public class TyrusNotificationService extends Object implements NotificationService, LifeCycle
NotificationService.Registration
Constructor and Description |
---|
TyrusNotificationService(URI uri,
IdGenerator idGenerator,
javax.websocket.ClientEndpointConfig.Configurator configurator,
Duration reconnectDelay,
TlsOptions tlsOptions)
Constructs a web-socket client with the given
uri , ID generator , configurator
and reconnection delay. |
Modifier and Type | Method and Description |
---|---|
Promise<NotificationService.Registration,NeverThrowsException> |
addConnectionEventListener(Consumer<ConnectionEvent> listener)
Registers asynchronously a listener that will be notified on connection/disconnection events.
|
void |
start()
Start the client, connecting the web-socket to the server.
|
void |
stop()
Stops this object.
|
Promise<Subscription,SubscriptionException> |
subscribe(String topic,
NotificationListener listener)
Subscribes (asynchronously) to a given topic, providing a listener
that will be invoked at notification reception time.
|
public TyrusNotificationService(URI uri, IdGenerator idGenerator, javax.websocket.ClientEndpointConfig.Configurator configurator, Duration reconnectDelay, TlsOptions tlsOptions)
uri
, ID generator
, configurator
and reconnection delay.uri
- web-socket server endpointidGenerator
- ID Generatorconfigurator
- Web-socket client configuratorreconnectDelay
- reconnection delay between attemptstlsOptions
- Security settings for the connection (may be null
)public void start() throws IOException, javax.websocket.DeploymentException
start
in interface LifeCycle
IOException
- if connection failedjavax.websocket.DeploymentException
- if connection failedpublic void stop()
LifeCycle
public Promise<Subscription,SubscriptionException> subscribe(String topic, NotificationListener listener)
NotificationService
subscribe
in interface NotificationService
topic
- topic name to subscribe tolistener
- notification listenerpublic Promise<NotificationService.Registration,NeverThrowsException> addConnectionEventListener(Consumer<ConnectionEvent> listener)
NotificationService
Promise
will be completed once the NotificationService
is connected.addConnectionEventListener
in interface NotificationService
listener
- consumer of connection eventsCopyright 2011-2017 ForgeRock AS.