Crossfire JXClient, Trunk
com.realtime.crossfire.jxclient.scripts.PacketWatcher Class Reference

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

+ Collaboration diagram for com.realtime.crossfire.jxclient.scripts.PacketWatcher:

Public Member Functions

void addCommand (@NotNull final String command)
 Adds a command to watch for. More...
 
void destroy ()
 Releases allocated resources. More...
 
 PacketWatcher (@NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final ScriptProcess scriptProcess)
 Creates a new instance. More...
 
void removeCommand (@NotNull final String command)
 Removes a command to watch for. More...
 

Private Member Functions

boolean matchesCommand (@NotNull final CharSequence command)
 Returns whether a command matches the currently watched commands. More...
 
void rebuildPattern ()
 Rebuilds pattern from commands. More...
 

Private Attributes

final Collection< String > commands = new HashSet<>()
 The commands to watch for. More...
 
final CrossfireServerConnection crossfireServerConnection
 The CrossfireServerConnection to watch. More...
 
Pattern pattern
 A Pattern matching all commands. More...
 
final ReceivedPacketListener receivedPacketListener
 The ReceivedPacketListener attached to crossfireServerConnection. More...
 
final ScriptProcess scriptProcess
 The ScriptProcess for sending commands. More...
 

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()

◆ 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

◆ 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.PacketWatcher.matchesCommand
boolean matchesCommand(@NotNull final CharSequence command)
Returns whether a command matches the currently watched commands.
Definition: PacketWatcher.java:158
com.realtime.crossfire.jxclient.scripts.PacketWatcher.scriptProcess
final ScriptProcess scriptProcess
The ScriptProcess for sending commands.
Definition: PacketWatcher.java:56
com.realtime.crossfire.jxclient.scripts.ScriptProcess.commandSent
void commandSent(@NotNull String cmd)
Sends a message to the script process.