TopicActiveDifficulty
, TopicBootstrap
, TopicConfirmation
, TopicStoppedElection
, TopicTelemetry
, TopicUnconfirmedBlocks
, TopicVote
, TopicWork
public class Topic<M> extends Object
Constructor | Description |
---|---|
Topic(String topicName,
NanoWebSocketClient client,
Class<M> classMessage) |
Modifier and Type | Method | Description |
---|---|---|
protected void |
_subscribe(Object options) |
|
protected boolean |
_subscribeBlocking(long timeout,
Object options) |
|
protected void |
_update(Object options) |
|
protected boolean |
_updateBlocking(long timeout,
Object options) |
|
protected com.google.gson.JsonObject |
createJson(String action) |
Creates a template
JsonObject for building requests. |
protected com.google.gson.JsonObject |
createJson(String action,
Object options) |
Creates a template
JsonObject for building requests. |
boolean |
deregisterListener(TopicListener<M> listener) |
De-registers a listener for this topic.
|
protected NanoWebSocketClient |
getClient() |
|
List<TopicListener<M>> |
getListeners() |
|
Class<M> |
getMessageClass() |
|
String |
getTopicName() |
|
void |
registerListener(TopicListener<M> listener) |
Registers a new listener for this topic.
|
void |
subscribe() |
Subscribe to this topic without any options or configurations.
|
boolean |
subscribeBlocking() |
Subscribe to this topic without any options or configurations.
|
boolean |
subscribeBlocking(long timeout) |
Subscribe to this topic without any options or configurations.
|
void |
unsubscribe() |
Unsubscribes from this topic without any options or configurations.
|
boolean |
unsubscribeBlocking() |
Unsubscribes from this topic without any options or configurations.
|
boolean |
unsubscribeBlocking(long timeout) |
Unsubscribes from this topic without any options or configurations.
|
public Topic(String topicName, NanoWebSocketClient client, Class<M> classMessage)
public final String getTopicName()
public final Class<M> getMessageClass()
protected final NanoWebSocketClient getClient()
public final void registerListener(TopicListener<M> listener)
listener
- the listener to registerpublic final boolean deregisterListener(TopicListener<M> listener)
listener
- the listener to removepublic final List<TopicListener<M>> getListeners()
public final void subscribe()
Subscribe to this topic without any options or configurations. The underlying WebSocket must be open before you call this method.
This method will process asynchronously and will not block the thread or verify completion.
IllegalStateException
- if the WebSocket is not currently openpublic final boolean subscribeBlocking() throws InterruptedException
Subscribe to this topic without any options or configurations. The underlying WebSocket must be open before you call this method.
This method will block indefinitely and wait for the associated acknowledgement message to be received before
continuing and returning true, false if the WebSocket closed, or throw an InterruptedException
if the
thread is interrupted.
IllegalStateException
- if the WebSocket is not currently openInterruptedException
- if the thread is interruptedpublic final boolean subscribeBlocking(long timeout) throws InterruptedException
Subscribe to this topic without any options or configurations. The underlying WebSocket must be open before you call this method.
This method will block indefinitely and wait for the associated acknowledgement message to be received before
continuing and returning true, false if the WebSocket closed, or throw an InterruptedException
if the
thread is interrupted.
IllegalStateException
- if the WebSocket is not currently openInterruptedException
- if the thread is interruptedpublic final void unsubscribe()
Unsubscribes from this topic without any options or configurations. The underlying WebSocket must be open before you call this method.
This method will process asynchronously and will not block the thread or verify completion.
IllegalStateException
- if the WebSocket is not currently openpublic final boolean unsubscribeBlocking() throws InterruptedException
Unsubscribes from this topic without any options or configurations. The underlying WebSocket must be open before you call this method.
This method will block indefinitely and wait for the associated acknowledgement message to be received before
continuing and returning true, false if the WebSocket closed, or throw an InterruptedException
if the
thread is interrupted.
IllegalStateException
- if the WebSocket is not currently openInterruptedException
- if the thread is interruptedpublic final boolean unsubscribeBlocking(long timeout) throws InterruptedException
Unsubscribes from this topic without any options or configurations. The underlying WebSocket must be open before you call this method.
This method will block and wait for the associated acknowledgement message to be received before
continuing and returning true, false if the WebSocket closed or the timeout period expires, or throw an
InterruptedException
if the thread is interrupted.
timeout
- the timeout in milliseconds, or zero for no timeoutIllegalStateException
- if the WebSocket is not currently openInterruptedException
- if the thread is interruptedprotected final void _subscribe(Object options)
protected final boolean _subscribeBlocking(long timeout, Object options) throws InterruptedException
InterruptedException
protected final void _update(Object options)
protected final boolean _updateBlocking(long timeout, Object options) throws InterruptedException
InterruptedException
protected final com.google.gson.JsonObject createJson(String action)
JsonObject
for building requests.action
- the action of the requestCopyright © 2020. All rights reserved.