java.lang.Objectcom.realtime.crossfire.jxclient.scripts.PacketWatcher
public class PacketWatcher
Implements the "watch" function for client-sided scripts.
| Field Summary | |
|---|---|
private java.util.Collection<java.lang.String> |
commands
The commands to watch for. |
private CrossfireServerConnection |
crossfireServerConnection
The CrossfireServerConnection to watch. |
private java.util.regex.Pattern |
pattern
A Pattern matching all commands. |
private ReceivedPacketListener |
receivedPacketListener
The ReceivedPacketListener attached to crossfireServerConnection. |
private ScriptProcess |
scriptProcess
The ScriptProcess for sending commands. |
| Constructor Summary | |
|---|---|
PacketWatcher(CrossfireServerConnection crossfireServerConnection,
ScriptProcess scriptProcess)
Creates a new instance. |
|
| Method Summary | |
|---|---|
void |
addCommand(java.lang.String command)
Adds a command to watch for. |
void |
destroy()
Releases allocated resources. |
private boolean |
matchesCommand(java.lang.CharSequence command)
Returns whether a command matches the currently watched commands. |
private void |
rebuildPattern()
Rebuilds pattern from commands. |
void |
removeCommand(java.lang.String command)
Removes a command to watch for. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
@NotNull private final java.util.Collection<java.lang.String> commands
@NotNull private final CrossfireServerConnection crossfireServerConnection
CrossfireServerConnection to watch.
@Nullable private java.util.regex.Pattern pattern
Pattern matching all commands. Set to
null when not watching for commands.
@NotNull private final ReceivedPacketListener receivedPacketListener
ReceivedPacketListener attached to crossfireServerConnection. It is attached if and only if pattern is non-null.
@NotNull private final ScriptProcess scriptProcess
ScriptProcess for sending commands.
| Constructor Detail |
|---|
public PacketWatcher(@NotNull
CrossfireServerConnection crossfireServerConnection,
@NotNull
ScriptProcess scriptProcess)
crossfireServerConnection - the server connection to watchscriptProcess - the script process for sending commands| Method Detail |
|---|
public void addCommand(@NotNull
java.lang.String command)
command - the commandpublic void destroy()
private boolean matchesCommand(@NotNull
java.lang.CharSequence command)
command - the command
private void rebuildPattern()
pattern from commands.
public void removeCommand(@NotNull
java.lang.String command)
command - the command