public class MetaserverProcessor
extends java.lang.Object
MetaserverModel
instance. Queries are performed regularly every UPDATE_INTERVAL
but
not faster than MIN_UPDATE_INTERVAL
. Queries can be stopped stopped
when the server selection GUI is left (disable()
; a call to query()
automatically re-starts queries.Modifier and Type | Field and Description |
---|---|
private int |
counter
Counter used by the query
runnable . |
private GuiStateListener |
guiStateListener
The
GuiStateListener for detecting established or dropped
connections. |
private Metaserver |
metaserver
The
Metaserver instance to forward to. |
private static int |
MIN_UPDATE_INTERVAL
The minimal update-interval in seconds.
|
private long |
nextQuery
The timestamp at which a query is allowed.
|
private java.lang.Runnable |
runnable
The query
Thread . |
private boolean |
running
Whether the query
runnable has been started. |
private java.lang.Object |
sync
The object used for synchronization.
|
private static int |
UPDATE_INTERVAL
The regular update-interval in seconds.
|
Constructor and Description |
---|
MetaserverProcessor(Metaserver metaserver,
GuiStateManager guiStateManager)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
disable()
Disables periodic re-queries.
|
void |
query()
Immediately triggers a metaserver query and enables periodic re-queries.
|
private int counter
runnable
. If positive, the value will
be decremented once per second; when it reaches zero, it is reset back to
UPDATE_INTERVAL
and a metaserver query is executed.
When set to zero, updating is disabled.
@NotNull private final GuiStateListener guiStateListener
GuiStateListener
for detecting established or dropped
connections.@NotNull private final Metaserver metaserver
Metaserver
instance to forward to.private static final int MIN_UPDATE_INTERVAL
private long nextQuery
MIN_UPDATE_INTERVAL
).@NotNull private final java.lang.Runnable runnable
Thread
.private boolean running
runnable
has been started.@NotNull private final java.lang.Object sync
private static final int UPDATE_INTERVAL
public MetaserverProcessor(@NotNull Metaserver metaserver, @NotNull GuiStateManager guiStateManager)
metaserver
- the metaserver instance to forward toguiStateManager
- the gui state manager to watchpublic void disable()
query()
.public void query()