com.realtime.crossfire.jxclient.metaserver
Class MetaserverProcessor

java.lang.Object
  extended by com.realtime.crossfire.jxclient.metaserver.MetaserverProcessor

public class MetaserverProcessor
extends java.lang.Object

Asynchronously queries the metaserver and updates a 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.


Field Summary
private  int counter
          Counter used by the query runnable.
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 Summary
MetaserverProcessor(Metaserver metaserver)
          Creates a new instance.
 
Method Summary
 void disable()
          Disables periodic re-queries.
 void query()
          Immediately triggers a metaserver query and enables periodic re-queries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

counter

private int counter
Counter used by the query 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.


metaserver

@NotNull
private final Metaserver metaserver
The Metaserver instance to forward to.


MIN_UPDATE_INTERVAL

private static final int MIN_UPDATE_INTERVAL
The minimal update-interval in seconds.

See Also:
Constant Field Values

nextQuery

private long nextQuery
The timestamp at which a query is allowed. Used to enforce minimum query intervals (MIN_UPDATE_INTERVAL).


runnable

@NotNull
private final java.lang.Runnable runnable
The query Thread.


running

private boolean running
Whether the query runnable has been started.


sync

@NotNull
private final java.lang.Object sync
The object used for synchronization.


UPDATE_INTERVAL

private static final int UPDATE_INTERVAL
The regular update-interval in seconds.

See Also:
Constant Field Values
Constructor Detail

MetaserverProcessor

public MetaserverProcessor(@NotNull
                           Metaserver metaserver)
Creates a new instance.

Parameters:
metaserver - the metaserver instance to forward to
Method Detail

disable

public void disable()
Disables periodic re-queries. Re-enable periodic queries with query().


query

public void query()
Immediately triggers a metaserver query and enables periodic re-queries. The immediate query is skipped if a recent query has been executed.