java.lang.Object com.realtime.crossfire.jxclient.queue.CommandQueue
public class CommandQueue
Maintains the pending (ncom) commands sent to the server.
Field Summary | |
---|---|
private CrossfireComcListener |
crossfireComcListener
The listener to track comc commands. |
private CrossfireServerConnection |
crossfireServerConnection
The server connection for sending ncom commands. |
private GuiStateListener |
guiStateListener
The GuiStateListener for detecting established or dropped
connections. |
private boolean |
isRunning
Whether a "run" command has been sent without a following "run_stop" command. |
private static int |
MAX_PENDING_COMMANDS
Maximum number of pending commands sent to the server. |
private java.util.List<java.lang.Integer> |
pendingCommands
Records command ids of commands sent to the server for which no comc commands has been received. |
private int |
repeatCount
The default repeat counter for ncom commands. |
Constructor Summary | |
---|---|
CommandQueue(CrossfireServerConnection crossfireServerConnection,
GuiStateManager guiStateManager)
Create a new instance. |
Method Summary | |
---|---|
void |
addToRepeatCount(int digit)
Add a digit to the current repeat count. |
boolean |
checkFire()
Returns whether the character is firing. |
boolean |
checkRun()
Returns whether the character is running. |
private void |
clear()
Forget about sent commands. |
private int |
getRepeatCount()
Return the current repeat count and reset it to zero. |
void |
resetRepeatCount()
Reset the current repeat count to zero. |
void |
sendMove(int to,
int tag)
Sends a "move" command to the server. |
void |
sendNcom(boolean mustSend,
int repeat,
java.lang.String command)
Send a "ncom" command to the server. |
void |
sendNcom(boolean mustSend,
java.lang.String command)
Send a "ncom" command to the server. |
boolean |
stopRunning()
Tell the server to stop running. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@NotNull private final CrossfireComcListener crossfireComcListener
@NotNull private final CrossfireServerConnection crossfireServerConnection
@NotNull private final GuiStateListener guiStateListener
GuiStateListener
for detecting established or dropped
connections.
private boolean isRunning
private static final int MAX_PENDING_COMMANDS
@NotNull private final java.util.List<java.lang.Integer> pendingCommands
MAX_PENDING_COMMANDS
due to "must send" commands.
private int repeatCount
Constructor Detail |
---|
public CommandQueue(@NotNull CrossfireServerConnection crossfireServerConnection, @NotNull GuiStateManager guiStateManager)
crossfireServerConnection
- The server connection for sending ncom
commands.guiStateManager
- the gui state manager to watchMethod Detail |
---|
public void addToRepeatCount(int digit)
digit
- The digit (0-9) to add.public boolean checkFire()
public boolean checkRun()
private void clear()
private int getRepeatCount()
public void resetRepeatCount()
public void sendMove(int to, int tag)
to
- the destination locationtag
- the item to movepublic void sendNcom(boolean mustSend, int repeat, @NotNull java.lang.String command)
mustSend
- If set, always send the command; if unset, drop the
command if the command queue is full.repeat
- The repeat count.command
- The command to send.sendNcom(boolean, String)
public void sendNcom(boolean mustSend, @NotNull java.lang.String command)
mustSend
- If set, always send the command; if unset, drop the
command if the command queue is full.command
- The command to send.sendNcom(boolean, int, String)
public boolean stopRunning()