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. |
Collection<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,
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@Nullable protected RemoteCommandListener getListenerFor(String command)
RemoteConnectionListener for the given command.public Collection<String> getRegisteredCommands()
CommandSenderProviderCommandSenderProvider.registerListener(RemoteCommandListener).getRegisteredCommands in interface CommandSenderProviderpublic void onError(RemoteConnection connection)
public void registerListener(RemoteCommandListener listener) throws IllegalStateException
CommandSenderProviderregisterListener in interface CommandSenderProviderlistener - the listener to registerIllegalStateException - if a listener is already registered for a command managed by the listenerpublic void sendNotification(RemoteNotification notification)
RemoteCommandManagersendNotification in interface RemoteCommandManagernotification - the notification to send.public void startReading(RemoteConnection connection)
startReading in interface RemoteCommandManagerconnection - the connection to read.public void startReading(RemoteConnection connection, RemoteConnectionListener listener)
startReading in interface RemoteCommandManagerconnection - the connection to read.listener - the associated listener.public void startReading(RemoteConnection connection, String connectionName)
startReading in interface RemoteCommandManagerconnection - the connection to read.connectionName - the name of the connection to read.public void startReading(RemoteConnection connection, String connectionName, @Nullable RemoteConnectionListener listener)
startReading in interface RemoteCommandManagerconnection - the connection to read.connectionName - the name of the connection to read.listener - the associated listener.public void stopAll()
RemoteCommandManagerstopAll in interface RemoteCommandManagerpublic void stopReading(RemoteConnection connection)
RemoteCommandManagerCommandReader.stopReading in interface RemoteCommandManagerconnection - the connection to stop to read.