Crossfire JXClient, Trunk
Public Member Functions | Private Member Functions | Private Attributes | List of all members
com.realtime.crossfire.jxclient.scripts.PacketWatcher Class Reference
Collaboration diagram for com.realtime.crossfire.jxclient.scripts.PacketWatcher:
Collaboration graph

Public Member Functions

void addCommand (@NotNull final String command)
 
void destroy ()
 
 PacketWatcher (@NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final ScriptProcess scriptProcess)
 
void removeCommand (@NotNull final String command)
 

Private Member Functions

boolean matchesCommand (@NotNull final CharSequence command)
 
void rebuildPattern ()
 

Private Attributes

final Collection< String > commands = new HashSet<>()
 
final CrossfireServerConnection crossfireServerConnection
 
Pattern pattern
 
final ReceivedPacketListener receivedPacketListener
 
final ScriptProcess scriptProcess
 

Detailed Description

Implements the "watch" function for client-sided scripts.

Author
Andreas Kirschbaum

Definition at line 38 of file PacketWatcher.java.

Constructor & Destructor Documentation

◆ PacketWatcher()

com.realtime.crossfire.jxclient.scripts.PacketWatcher.PacketWatcher ( @NotNull final CrossfireServerConnection  crossfireServerConnection,
@NotNull final ScriptProcess  scriptProcess 
)

Creates a new instance.

Parameters
crossfireServerConnectionthe server connection to watch
scriptProcessthe script process for sending commands

Definition at line 92 of file PacketWatcher.java.

References com.realtime.crossfire.jxclient.scripts.PacketWatcher.crossfireServerConnection, com.realtime.crossfire.jxclient.scripts.PacketWatcher.rebuildPattern(), and com.realtime.crossfire.jxclient.scripts.PacketWatcher.scriptProcess.

Here is the call graph for this function:

Member Function Documentation

◆ addCommand()

void com.realtime.crossfire.jxclient.scripts.PacketWatcher.addCommand ( @NotNull final String  command)

Adds a command to watch for.

Parameters
commandthe command

Definition at line 137 of file PacketWatcher.java.

References com.realtime.crossfire.jxclient.scripts.PacketWatcher.commands, and com.realtime.crossfire.jxclient.scripts.PacketWatcher.rebuildPattern().

Referenced by com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess.runScriptCommand(), and com.realtime.crossfire.jxclient.scripts.PacketWatcherTest.test1().

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

◆ destroy()

void com.realtime.crossfire.jxclient.scripts.PacketWatcher.destroy ( )

◆ matchesCommand()

boolean com.realtime.crossfire.jxclient.scripts.PacketWatcher.matchesCommand ( @NotNull final CharSequence  command)
private

Returns whether a command matches the currently watched commands.

Parameters
commandthe command
Returns
whether the command matches

Definition at line 158 of file PacketWatcher.java.

References com.realtime.crossfire.jxclient.scripts.PacketWatcher.pattern.

◆ rebuildPattern()

void com.realtime.crossfire.jxclient.scripts.PacketWatcher.rebuildPattern ( )
private

◆ removeCommand()

void com.realtime.crossfire.jxclient.scripts.PacketWatcher.removeCommand ( @NotNull final String  command)

Removes a command to watch for.

Parameters
commandthe command

Definition at line 147 of file PacketWatcher.java.

References com.realtime.crossfire.jxclient.scripts.PacketWatcher.commands, and com.realtime.crossfire.jxclient.scripts.PacketWatcher.rebuildPattern().

Referenced by com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess.runScriptCommand().

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

Member Data Documentation

◆ commands

final Collection<String> com.realtime.crossfire.jxclient.scripts.PacketWatcher.commands = new HashSet<>()
private

◆ crossfireServerConnection

final CrossfireServerConnection com.realtime.crossfire.jxclient.scripts.PacketWatcher.crossfireServerConnection
private

◆ pattern

Pattern com.realtime.crossfire.jxclient.scripts.PacketWatcher.pattern
private

◆ receivedPacketListener

final ReceivedPacketListener com.realtime.crossfire.jxclient.scripts.PacketWatcher.receivedPacketListener
private
Initial value:
= new ReceivedPacketListener() {
@Override
public void process(@NotNull final String command, @NotNull final ClientSocketMonitorCommand args) {
if (matchesCommand(command)) {
final String args2 = args.getMonitorCommand();
if (args2.isEmpty()) {
scriptProcess.commandSent("watch "+command);
} else {
scriptProcess.commandSent("watch "+command+" "+args2);
}
}
}
}

The ReceivedPacketListener attached to crossfireServerConnection. It is attached if and only if pattern is non-

null

.

Definition at line 71 of file PacketWatcher.java.

Referenced by com.realtime.crossfire.jxclient.scripts.PacketWatcher.destroy(), and com.realtime.crossfire.jxclient.scripts.PacketWatcher.rebuildPattern().

◆ scriptProcess

final ScriptProcess com.realtime.crossfire.jxclient.scripts.PacketWatcher.scriptProcess
private

The ScriptProcess for sending commands.

Definition at line 56 of file PacketWatcher.java.

Referenced by com.realtime.crossfire.jxclient.scripts.PacketWatcher.PacketWatcher().


The documentation for this class was generated from the following file:
com.realtime.crossfire.jxclient.scripts.ScriptProcess.commandSent
void commandSent(@NotNull String cmd)
com.realtime.crossfire.jxclient.scripts.PacketWatcher.matchesCommand
boolean matchesCommand(@NotNull final CharSequence command)
Definition: PacketWatcher.java:158
com.realtime.crossfire.jxclient.scripts.PacketWatcher.scriptProcess
final ScriptProcess scriptProcess
Definition: PacketWatcher.java:56