public class DefaultRemoteCommandManager extends Object implements RemoteCommandManager
Constructor and Description |
---|
DefaultRemoteCommandManager()
Creates a default remote command manager.
|
DefaultRemoteCommandManager(boolean overwrite)
Creates a default remote command manager.
|
Modifier and Type | Method and Description |
---|---|
Collection<? extends CommandSender> |
getCommandSenders(String command)
Returns the command senders that handle the given command.
|
protected RemoteCommandListener |
getListenerFor(String command)
Returns the
RemoteConnectionListener for the given command. |
void |
onError(RemoteConnection connection)
Called when an error occurs in the given connection
|
void |
registerListener(RemoteCommandListener listener)
Registers a listener that will be called when command managed by the listener is read.
|
void |
startReading(RemoteConnection connection)
Can be called once.
|
void |
startReading(RemoteConnection connection,
RemoteConnectionListener listener)
Can be called once.
|
void |
startReading(RemoteConnection connection,
String connectionName)
Can be called once.
|
void |
startReading(RemoteConnection connection,
String connectionName,
RemoteConnectionListener listener)
Can be called once.
|
void |
stopAll()
Stops all the connections.
|
void |
stopReading(RemoteConnection connection)
Stops reading the commands from the given
CommandReader . |
public DefaultRemoteCommandManager()
Equivalent as calling DefaultRemoteCommandManager(boolean)
with
false
as parameter.
public DefaultRemoteCommandManager(boolean overwrite)
It is possible to choose the policy when a listener is registered that manage the same command as another one. Either drop the new one or overwrite the old one.
overwrite
- the listener policy, true
to overwrite the old one, false
otherwise.public Collection<? extends CommandSender> getCommandSenders(String command)
CommandSenderProvider
Synchronize on this CommandSenderProvider
while using the
returned collection to avoid concurrent modifications of the collection.
getCommandSenders
in interface CommandSenderProvider
protected RemoteCommandListener getListenerFor(String command)
RemoteConnectionListener
for the given command.public void onError(RemoteConnection connection)
public void registerListener(RemoteCommandListener listener) throws IllegalStateException
CommandSenderProvider
registerListener
in interface CommandSenderProvider
listener
- the listener to registerIllegalStateException
- if a listener is already registered for a command managed by the listenerpublic void startReading(RemoteConnection connection)
startReading
in interface RemoteCommandManager
connection
- the connection to read.public void startReading(RemoteConnection connection, RemoteConnectionListener listener)
startReading
in interface RemoteCommandManager
connection
- the connection to read.listener
- the associated listener.public void startReading(RemoteConnection connection, String connectionName)
startReading
in interface RemoteCommandManager
connection
- the connection to read.connectionName
- the name of the connection to read.public void startReading(RemoteConnection connection, String connectionName, RemoteConnectionListener listener)
startReading
in interface RemoteCommandManager
connection
- the connection to read.connectionName
- the name of the connection to read.listener
- the associated listener.public void stopAll()
RemoteCommandManager
stopAll
in interface RemoteCommandManager
public void stopReading(RemoteConnection connection)
RemoteCommandManager
CommandReader
.stopReading
in interface RemoteCommandManager
connection
- the connection to stop to read.