Crossfire JXClient, Trunk
R20561
|
Implements the "watch" function for client-sided scripts. More...
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... | |
Implements the "watch" function for client-sided scripts.
Definition at line 37 of file PacketWatcher.java.
com.realtime.crossfire.jxclient.scripts.PacketWatcher.PacketWatcher | ( | @NotNull final CrossfireServerConnection | crossfireServerConnection, |
@NotNull final ScriptProcess | scriptProcess | ||
) |
Creates a new instance.
crossfireServerConnection | the server connection to watch |
scriptProcess | the 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.
void com.realtime.crossfire.jxclient.scripts.PacketWatcher.addCommand | ( | @NotNull final String | command | ) |
Adds a command to watch for.
command | the 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().
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().
|
private |
Returns whether a command matches the currently watched commands.
command | the command |
Definition at line 244 of file PacketWatcher.java.
|
private |
Rebuilds pattern from commands.
Definition at line 198 of file PacketWatcher.java.
References com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.addPacketWatcherListener(), and com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.removePacketWatcherListener().
Referenced by com.realtime.crossfire.jxclient.scripts.PacketWatcher.addCommand(), com.realtime.crossfire.jxclient.scripts.PacketWatcher.PacketWatcher(), and com.realtime.crossfire.jxclient.scripts.PacketWatcher.removeCommand().
void com.realtime.crossfire.jxclient.scripts.PacketWatcher.removeCommand | ( | @NotNull final String | command | ) |
Removes a command to watch for.
command | the 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().
|
private |
The commands to watch for.
Definition at line 43 of file PacketWatcher.java.
|
private |
The CrossfireServerConnection to watch.
Definition at line 49 of file PacketWatcher.java.
Referenced by com.realtime.crossfire.jxclient.scripts.PacketWatcher.PacketWatcher().
|
private |
A Pattern matching all commands.
Set to
when not watching for commands.
Definition at line 62 of file PacketWatcher.java.
|
private |
The ReceivedPacketListener attached to crossfireServerConnection.
It is attached if and only if pattern is non-
.
Definition at line 70 of file PacketWatcher.java.
|
private |
The ScriptProcess for sending commands.
Definition at line 55 of file PacketWatcher.java.
Referenced by com.realtime.crossfire.jxclient.scripts.PacketWatcher.PacketWatcher().