public class DefaultRemoteCommandManager extends java.lang.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 |
---|---|
java.util.Collection<? extends CommandSender> |
getCommandSenders(java.lang.String command)
Returns the command senders that handle the given command.
|
protected RemoteCommandListener |
getListenerFor(java.lang.String command)
Returns the
RemoteConnectionListener for the given command. |
java.util.Collection<java.lang.String> |
getRegisteredCommands()
Gets the collections of registered commands with
CommandSenderProvider.registerListener(RemoteCommandListener) . |
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 |
sendNotification(RemoteNotification notification)
Sends the given notification to all connected clients.
|
void |
startReading(RemoteConnection connection)
Can be called once.
|
void |
startReading(RemoteConnection connection,
RemoteConnectionListener listener)
Can be called once.
|
void |
startReading(RemoteConnection connection,
java.lang.String connectionName)
Can be called once.
|
void |
startReading(RemoteConnection connection,
java.lang.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(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 DefaultRemoteCommandManager()
Equivalent as calling DefaultRemoteCommandManager(boolean)
with
false
as parameter.
public void registerListener(RemoteCommandListener listener) throws java.lang.IllegalStateException
CommandSenderProvider
registerListener
in interface CommandSenderProvider
listener
- the listener to registerjava.lang.IllegalStateException
- if a listener is already registered for a command managed by the listener@Nullable protected RemoteCommandListener getListenerFor(java.lang.String command)
RemoteConnectionListener
for the given command.public 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, java.lang.String connectionName)
startReading
in interface RemoteCommandManager
connection
- the connection to read.connectionName
- the name of the connection to read.public void startReading(RemoteConnection connection, java.lang.String connectionName, @Nullable 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 stopReading(RemoteConnection connection)
RemoteCommandManager
CommandReader
.stopReading
in interface RemoteCommandManager
connection
- the connection to stop to read.public void onError(RemoteConnection connection)
public void stopAll()
RemoteCommandManager
stopAll
in interface RemoteCommandManager
public java.util.Collection<? extends CommandSender> getCommandSenders(java.lang.String command)
CommandSenderProvider
Synchronize on this CommandSenderProvider
while using the returned collection to avoid concurrent
modifications of the collection.
getCommandSenders
in interface CommandSenderProvider
public java.util.Collection<java.lang.String> getRegisteredCommands()
CommandSenderProvider
CommandSenderProvider.registerListener(RemoteCommandListener)
.getRegisteredCommands
in interface CommandSenderProvider
public void sendNotification(RemoteNotification notification)
RemoteCommandManager
sendNotification
in interface RemoteCommandManager
notification
- the notification to send.