Crossfire JXClient, Trunk  R20561
com.realtime.crossfire.jxclient.queue.CommandQueue Class Reference

Maintains the pending (ncom) commands sent to the server. More...

+ Collaboration diagram for com.realtime.crossfire.jxclient.queue.CommandQueue:

Public Member Functions

void addToRepeatCount (final int digit)
 Adds a digit to the current repeat count. More...
 
boolean checkFire ()
 Returns whether the character is firing. More...
 
boolean checkRun ()
 Returns whether the character is running. More...
 
 CommandQueue (@NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final GuiStateManager guiStateManager)
 Creates a new instance. More...
 
void resetRepeatCount ()
 Resets the current repeat count to zero. More...
 
void sendMove (final int to, final int tag)
 Sends a "move" command to the server. More...
 
void sendNcom (final boolean mustSend, @NotNull final String command)
 Sends an "ncom" command to the server. More...
 
void sendNcom (final boolean mustSend, final int repeat, @NotNull final String command)
 Sends an "ncom" command to the server. More...
 
boolean stopRunning ()
 Tells the server to stop running. More...
 

Private Member Functions

void clear ()
 Forgets about sent commands. More...
 
int getRepeatCount ()
 Returns the current repeat count and reset it to zero. More...
 

Private Attributes

final CrossfireComcListener crossfireComcListener
 The listener to track comc commands. More...
 
final CrossfireServerConnection crossfireServerConnection
 The server connection for sending ncom commands. More...
 
final GuiStateListener guiStateListener
 The GuiStateListener for detecting established or dropped connections. More...
 
boolean isRunning
 Whether a "run" command has been sent without a following "run_stop" command. More...
 
final List< Integer > pendingCommands = new LinkedList<>()
 Records command ids of commands sent to the server for which no comc commands has been received. More...
 
int repeatCount
 The default repeat counter for ncom commands. More...
 

Static Private Attributes

static final int MAX_PENDING_COMMANDS = 10
 Maximum number of pending commands sent to the server. More...
 

Detailed Description

Maintains the pending (ncom) commands sent to the server.

Author
Andreas Kirschbaum

Definition at line 37 of file CommandQueue.java.

Constructor & Destructor Documentation

◆ CommandQueue()

com.realtime.crossfire.jxclient.queue.CommandQueue.CommandQueue ( @NotNull final CrossfireServerConnection  crossfireServerConnection,
@NotNull final GuiStateManager  guiStateManager 
)

Creates a new instance.

Parameters
crossfireServerConnectionthe server connection for sending ncom commands
guiStateManagerthe gui state manager to watch

Definition at line 143 of file CommandQueue.java.

References com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.addCrossfireComcListener(), com.realtime.crossfire.jxclient.queue.CommandQueue.crossfireComcListener, com.realtime.crossfire.jxclient.queue.CommandQueue.crossfireServerConnection, and com.realtime.crossfire.jxclient.queue.CommandQueue.guiStateListener.

+ Here is the call graph for this function:

Member Function Documentation

◆ addToRepeatCount()

void com.realtime.crossfire.jxclient.queue.CommandQueue.addToRepeatCount ( final int  digit)

Adds a digit to the current repeat count.

Parameters
digitthe digit (0-9) to add

Definition at line 170 of file CommandQueue.java.

References com.realtime.crossfire.jxclient.queue.CommandQueue.repeatCount.

Referenced by com.realtime.crossfire.jxclient.window.KeyHandler.handleKeyPress().

+ Here is the caller graph for this function:

◆ checkFire()

boolean com.realtime.crossfire.jxclient.queue.CommandQueue.checkFire ( )

Returns whether the character is firing.

Returns
whether the character is firing MethodMayBeStatic

Definition at line 254 of file CommandQueue.java.

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdRequest().

+ Here is the caller graph for this function:

◆ checkRun()

boolean com.realtime.crossfire.jxclient.queue.CommandQueue.checkRun ( )

Returns whether the character is running.

Returns
whether the character is running

Definition at line 243 of file CommandQueue.java.

References com.realtime.crossfire.jxclient.queue.CommandQueue.isRunning, and com.realtime.crossfire.jxclient.queue.CommandQueue.pendingCommands.

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdRequest().

+ Here is the caller graph for this function:

◆ clear()

void com.realtime.crossfire.jxclient.queue.CommandQueue.clear ( )
private

◆ getRepeatCount()

int com.realtime.crossfire.jxclient.queue.CommandQueue.getRepeatCount ( )
private

Returns the current repeat count and reset it to zero.

Returns
the current repeat count

Definition at line 153 of file CommandQueue.java.

References com.realtime.crossfire.jxclient.queue.CommandQueue.repeatCount, and com.realtime.crossfire.jxclient.queue.CommandQueue.resetRepeatCount().

Referenced by com.realtime.crossfire.jxclient.queue.CommandQueue.sendMove(), and com.realtime.crossfire.jxclient.queue.CommandQueue.sendNcom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetRepeatCount()

void com.realtime.crossfire.jxclient.queue.CommandQueue.resetRepeatCount ( )

Resets the current repeat count to zero.

Definition at line 162 of file CommandQueue.java.

References com.realtime.crossfire.jxclient.queue.CommandQueue.repeatCount.

Referenced by com.realtime.crossfire.jxclient.queue.CommandQueue.clear(), and com.realtime.crossfire.jxclient.queue.CommandQueue.getRepeatCount().

+ Here is the caller graph for this function:

◆ sendMove()

void com.realtime.crossfire.jxclient.queue.CommandQueue.sendMove ( final int  to,
final int  tag 
)

Sends a "move" command to the server.

The repeat count value is the client's current repeat count.

Parameters
tothe destination location
tagthe item to move

Definition at line 264 of file CommandQueue.java.

References com.realtime.crossfire.jxclient.queue.CommandQueue.crossfireServerConnection, com.realtime.crossfire.jxclient.queue.CommandQueue.getRepeatCount(), and com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.sendMove().

Referenced by com.realtime.crossfire.jxclient.gui.item.GUIItemFloor.button3Clicked(), and com.realtime.crossfire.jxclient.gui.item.GUIItemInventory.button3Clicked().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendNcom() [1/2]

◆ sendNcom() [2/2]

void com.realtime.crossfire.jxclient.queue.CommandQueue.sendNcom ( final boolean  mustSend,
final int  repeat,
@NotNull final String  command 
)

Sends an "ncom" command to the server.

Parameters
mustSendif set, always send the command; if unset, drop the command if the command queue is full
repeatthe repeat count
commandthe command to send
See also
#sendNcom(boolean, String)

Definition at line 206 of file CommandQueue.java.

References com.realtime.crossfire.jxclient.queue.CommandQueue.crossfireServerConnection, com.realtime.crossfire.jxclient.queue.CommandQueue.isRunning, com.realtime.crossfire.jxclient.queue.CommandQueue.MAX_PENDING_COMMANDS, com.realtime.crossfire.jxclient.queue.CommandQueue.pendingCommands, and com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.sendNcom().

+ Here is the call graph for this function:

◆ stopRunning()

boolean com.realtime.crossfire.jxclient.queue.CommandQueue.stopRunning ( )

Tells the server to stop running.

If the character is not running, does nothing.

Returns
whether running was active

Definition at line 228 of file CommandQueue.java.

References com.realtime.crossfire.jxclient.queue.CommandQueue.isRunning, com.realtime.crossfire.jxclient.queue.CommandQueue.pendingCommands, and com.realtime.crossfire.jxclient.queue.CommandQueue.sendNcom().

Referenced by com.realtime.crossfire.jxclient.window.KeyHandler.updateModifiers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ crossfireComcListener

final CrossfireComcListener com.realtime.crossfire.jxclient.queue.CommandQueue.crossfireComcListener
private
Initial value:
= (packetNo, time) -> {
synchronized (pendingCommands) {
final int index = pendingCommands.indexOf(packetNo);
if (index == -1) {
System.err.println("Error: got unexpected comc command #"+packetNo);
return;
}
if (index > 0) {
System.err.println("Warning: got out of order comc command #"+packetNo);
}
for (int i = 0; i <= index; i++) {
pendingCommands.remove(0);
}
}
}

The listener to track comc commands.

Definition at line 75 of file CommandQueue.java.

Referenced by com.realtime.crossfire.jxclient.queue.CommandQueue.CommandQueue().

◆ crossfireServerConnection

final CrossfireServerConnection com.realtime.crossfire.jxclient.queue.CommandQueue.crossfireServerConnection
private

◆ guiStateListener

final GuiStateListener com.realtime.crossfire.jxclient.queue.CommandQueue.guiStateListener
private

The GuiStateListener for detecting established or dropped connections.

Definition at line 98 of file CommandQueue.java.

Referenced by com.realtime.crossfire.jxclient.queue.CommandQueue.CommandQueue().

◆ isRunning

boolean com.realtime.crossfire.jxclient.queue.CommandQueue.isRunning
private

◆ MAX_PENDING_COMMANDS

final int com.realtime.crossfire.jxclient.queue.CommandQueue.MAX_PENDING_COMMANDS = 10
staticprivate

Maximum number of pending commands sent to the server.

Excess commands will be dropped.

Definition at line 43 of file CommandQueue.java.

Referenced by com.realtime.crossfire.jxclient.queue.CommandQueue.sendNcom().

◆ pendingCommands

final List<Integer> com.realtime.crossfire.jxclient.queue.CommandQueue.pendingCommands = new LinkedList<>()
private

Records command ids of commands sent to the server for which no comc commands has been received.

Note that the size may be larger than MAX_PENDING_COMMANDS due to "must send" commands.

Definition at line 57 of file CommandQueue.java.

Referenced by com.realtime.crossfire.jxclient.queue.CommandQueue.checkRun(), com.realtime.crossfire.jxclient.queue.CommandQueue.clear(), com.realtime.crossfire.jxclient.queue.CommandQueue.sendNcom(), and com.realtime.crossfire.jxclient.queue.CommandQueue.stopRunning().

◆ repeatCount

int com.realtime.crossfire.jxclient.queue.CommandQueue.repeatCount
private

The documentation for this class was generated from the following file: