Interface UDPAccessor
Allows sending of UDP commands, and adding or removal of UDP command listeners.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addUDPCommandListener
(String command, UDPCommandListener udpCommandListener) Adds the command listener for the specified command.boolean
removeUDPCommandListener
(String command, UDPCommandListener udpCommandListener) Removes the command listener for the specified command.void
Sends the specified command and arguments string to the default destination.void
send
(String commandAndArguments, InetAddress address, int port) Sends the specified command and arguments string to the specified address and port.
-
Method Details
-
addUDPCommandListener
Adds the command listener for the specified command. The listener will now be informed each time that command is executed.
If a particular listener is added mulitple times for the same command, then it will be informed of a single execution of that command multiple times.
A particular listener can be used to listen to multiple commands. If this is the case, then the listener can identify which command was executed from the first command argument - this is always the name of the command itself.
- Parameters:
command
- The command that the listener is being added for.udpCommandListener
- The listener that should be informed when the command is executed.
-
removeUDPCommandListener
boolean removeUDPCommandListener(String command, UDPCommandListener udpCommandListener) throws UDPCommandRemovalException Removes the command listener for the specified command. If the listener is successfully removed it will no longer be informed whenever that command is executed.
If a listener has been added multiple times for the same command, only the first occurrence will be removed.
- Parameters:
command
- The command that the listener is being added for.udpCommandListener
- The listener that should be informed when the command is executed.- Returns:
- true if the command was successfully removed, otherwise false.
- Throws:
UDPCommandRemovalException
- If the last listener for a particular command is removed, and the implementation is unable to find the command to remove.UDPCommandRemovalException
- If either the command or udpCommandListener arguments are null.
-
send
Sends the specified command and arguments string to the default destination. The string should begin with the command, with the arguments included afterwards, separated with spaces.
For example:
send("memory_write")
send("symbol_publish LON* NY* JPN*")
- Parameters:
commandAndArguments
- The command to send and its arguments, in a space separated list.- Throws:
UDPSendException
- If the commandAndArguments argument is null.
-
send
Sends the specified command and arguments string to the specified address and port. The string should begin with the command, with the arguments included afterwards, separated with spaces.
For example:
send("memory_write")
send("symbol_publish LON* NY* JPN*")
- Parameters:
commandAndArguments
- The command to send and its arguments, in a space separated list.address
- The address to send the command toport
- The prot to send the command to- Throws:
UDPSendException
- If the commandAndArguments argument is null.
-