public class NumLookObjects
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private boolean |
connected
Whether the current client socket state is
ClientSocketState.CONNECTED . |
private CrossfireServerConnection |
crossfireServerConnection
The
CrossfireServerConnection for sending "setup" commands. |
private int |
currentNumLookObjects
The currently active number of ground view objects.
|
private DebugWriter |
debugProtocol
The appender to write protocol commands to.
|
private static int |
DEFAULT_NUM_LOOK_OBJECTS
The default number of ground objects when no "setup num_look_objects"
command has been sent.
|
private boolean |
pending
Whether negotiation may be pending.
|
private int |
pendingNumLookObjects
The number of ground view objects being negotiated with the server.
|
private int |
preferredNumLookObjects
The number of ground view objects to be negotiated with the server.
|
private java.lang.Object |
sync
The synchronization objects for accessing mutable fields.
|
Constructor and Description |
---|
NumLookObjects(CrossfireServerConnection crossfireServerConnection,
DebugWriter debugProtocol)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
connected()
Called after the server connection has been established.
|
int |
getCurrentNumLookObjects()
Returns the current number of ground items.
|
private void |
negotiateNumLookObjects()
Requests a change of the number of ground objects from the server.
|
void |
processSetupNumLookObjects(java.lang.String value)
Called when a "setup num_look_objects" response has been received from
the server.
|
void |
setClientSocketState(ClientSocketState clientSocketState)
Called whenever the client socket state has changed.
|
void |
setPreferredNumLookObjects(int preferredNumLookObjects)
Sets the preferred number of ground items.
|
void |
waitForCurrentNumLookObjectsValid()
Waits until
getCurrentNumLookObjects() is stable. |
private boolean connected
ClientSocketState.CONNECTED
.@NotNull private final CrossfireServerConnection crossfireServerConnection
CrossfireServerConnection
for sending "setup" commands.private int currentNumLookObjects
@Nullable private final DebugWriter debugProtocol
null
to not
write anything.private static final int DEFAULT_NUM_LOOK_OBJECTS
private boolean pending
private int pendingNumLookObjects
0
when not negotiating.private int preferredNumLookObjects
@NotNull private final java.lang.Object sync
NumLookObjects(@NotNull CrossfireServerConnection crossfireServerConnection, @Nullable DebugWriter debugProtocol)
crossfireServerConnection
- the crossfire server connection for
sending setup commandsdebugProtocol
- the appender for writing debug messages to or null
to not write debug messagespublic void connected()
public int getCurrentNumLookObjects()
private void negotiateNumLookObjects()
public void processSetupNumLookObjects(@NotNull java.lang.String value) throws UnknownCommandException
value
- the value of the messageUnknownCommandException
- if the value cannot be parsedpublic void setClientSocketState(@NotNull ClientSocketState clientSocketState)
clientSocketState
- the new client socket statepublic void setPreferredNumLookObjects(int preferredNumLookObjects)
preferredNumLookObjects
- the number of ground itemspublic void waitForCurrentNumLookObjectsValid() throws java.lang.InterruptedException
getCurrentNumLookObjects()
is stable. This function
returns as soon as the negotiation with the Crossfire server is
complete.java.lang.InterruptedException
- if the current thread was interrupted