Crossfire JXClient, Trunk  R20561
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 37 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 178 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 223 of file PacketWatcher.java.

References com.realtime.crossfire.jxclient.scripts.PacketWatcher.rebuildPattern().

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.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 ( )

Releases allocated resources.

Must be called before this instance is freed.

Definition at line 188 of file PacketWatcher.java.

References com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.removePacketWatcherListener().

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

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

◆ 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 244 of file PacketWatcher.java.

◆ 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 233 of file PacketWatcher.java.

References com.realtime.crossfire.jxclient.scripts.PacketWatcher.rebuildPattern().

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.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

The commands to watch for.

Definition at line 43 of file PacketWatcher.java.

◆ crossfireServerConnection

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

◆ pattern

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

A Pattern matching all commands.

Set to

null

when not watching for commands.

Definition at line 62 of file PacketWatcher.java.

◆ receivedPacketListener

final ReceivedPacketListener com.realtime.crossfire.jxclient.scripts.PacketWatcher.receivedPacketListener
private

The ReceivedPacketListener attached to crossfireServerConnection.

It is attached if and only if pattern is non-

null

.

Definition at line 70 of file PacketWatcher.java.

◆ scriptProcess

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

The ScriptProcess for sending commands.

Definition at line 55 of file PacketWatcher.java.

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


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