|
cybergarage-upnp
|
Static Public Member Functions | |
| static boolean | isActionNode (Node node) |
Static Public Attributes | |
| static final String | ELEM_NAME = "action" |
Private Member Functions | |
| Node | getServiceNode () |
| void | clearOutputAgumentValues () |
| ActionData | getActionData () |
| ControlResponse | getControlResponse () |
| void | setControlResponse (ControlResponse res) |
Private Attributes | |
| Node | serviceNode |
| Node | actionNode |
| Mutex | mutex = new Mutex() |
| UPnPStatus | upnpStatus = new UPnPStatus() |
| Object | userData = null |
Static Private Attributes | |
| static final String | NAME = "name" |
Represents a UPnP action that can be invoked on a service.
Actions are methods exposed by UPnP services that can be called remotely by control points. Each action has a name, a list of input arguments, and a list of output arguments. Actions are defined in the service's SCPD (Service Control Protocol Definition) document.
This class provides methods to:
postControlAction() ActionListener Thread-safety: This class uses internal synchronization via lock() and unlock() methods. Multiple threads can safely interact with the same action instance when using these synchronization methods.
Example usage for invoking an action on a device:
Service service = device.getService("urn:schemas-upnp-org:service:AVTransport:1");
Action playAction = service.getAction("Play");
playAction.setArgumentValue("InstanceID", "0");
playAction.setArgumentValue("Speed", "1");
boolean success = playAction.postControlAction();
if (success) {
System.out.println("Play action executed successfully");
}
|
inline |
Constructs a new action with the specified service node.
Creates an empty action node that can be populated with action details.
| serviceNode | the XML node representing the service that contains this action |
Constructs an action from existing service and action XML nodes.
This constructor is typically used when parsing service descriptions to create action objects from the SCPD document.
| serviceNode | the XML node representing the parent service |
| actionNode | the XML node containing action definition and arguments |
|
inline |
Creates a copy of an existing action.
Note: This creates a shallow copy that references the same underlying XML nodes as the original action.
| action | the action to copy |
|
inlineprivate |
|
inlineprivate |
|
inline |
Returns the action listener registered for this action.
null if none is registered
|
inline |
Returns the underlying XML node representing this action.
|
inline |
Returns the argument with the specified name.
| name | the name of the argument to retrieve |
null if not found
|
inline |
Returns the integer value of the specified argument.
| name | the name of the argument |
|
inline |
Returns the complete list of arguments for this action.
This includes both input and output arguments as defined in the service's SCPD document.
|
inline |
Returns the string value of the specified argument.
| name | the name of the argument |
|
inlineprivate |
|
inline |
|
inline |
Returns only the input arguments for this action.
Input arguments are those with direction "in" and must be provided when invoking the action on a device.
|
inline |
Returns the name of this action.
|
inline |
Returns only the output arguments for this action.
Output arguments are those with direction "out" and are populated with values returned by the device after action execution.
|
inline |
Returns the service that contains this action.
|
inlineprivate |
|
inline |
Returns the current execution status of this action.
The status includes error codes and descriptions from the most recent action execution.
|
inline |
Returns the custom user data associated with this action.
null if none has been set
|
inlinestatic |
Checks if the given XML node represents an action element.
| node | the XML node to check |
true if the node's name matches the action element name, false otherwise
|
inline |
|
inline |
Executes the action listener for an incoming action request.
This method is called by the UPnP device when a control point invokes this action. It calls the registered ActionListener, collects the response, and posts it back to the control point.
| actionReq | the incoming action request from the control point |
true if a listener was registered and executed, false if no listener is available
|
inline |
Posts this action to the device and waits for the response.
This method sends a SOAP action request to the device's control URL with the currently set input argument values. It blocks until a response is received or a timeout occurs. Upon successful execution, the output argument values are updated with the response data.
The execution status can be retrieved via getStatus() after this method returns.
true if the action was executed successfully and the response was valid,
false if an error occurred
|
inline |
Prints action information to standard output for debugging.
Outputs the action name and all argument details including direction, name, and current value.
|
inline |
Sets the listener that will be notified when this action is invoked.
The listener's ActionListener#actionControlReceived(Action) method will be called when a control point invokes this action.
| listener | the action listener to set, or null to remove the listener |
|
inline |
Sets the argument list for this action.
Replaces the existing argument list with the provided list. This method ensures that all arguments are properly associated with the action's service.
| al | the argument list to set |
|
inline |
Sets the value of a named argument from an integer.
The integer value is converted to a string before being assigned. If the argument with the specified name does not exist, this method does nothing.
| name | the name of the argument to set |
| value | the integer value to assign to the argument |
|
inline |
Sets the value of a named argument.
If the argument with the specified name does not exist, this method does nothing.
| name | the name of the argument to set |
| value | the string value to assign to the argument |
|
inline |
Sets argument values from the provided list.
| argList | the argument list containing values to set |
|
inlineprivate |
|
inline |
Sets the values of input arguments from the provided argument list.
Only the values of arguments with direction "in" are updated.
| argList | the argument list containing values to set |
|
inline |
Sets the name of this action.
| value | the action name (e.g., "Play", "SetVolume") |
|
inline |
Sets the values of output arguments from the provided argument list.
Only the values of arguments with direction "out" are updated.
| argList | the argument list containing values to set |
|
inline |
Sets the execution status of this action with a specific error code.
The description is automatically derived from the error code.
| code | the UPnP error code |
|
inline |
Sets the execution status of this action with a specific error code and description.
| code | the UPnP error code |
| descr | the human-readable description of the error |
|
inline |
Sets custom user data associated with this action.
This allows applications to attach arbitrary data to an action instance for application-specific purposes.
| data | the user data object to associate with this action |
|
inline |
|
private |
|
static |
The XML element name for action nodes in SCPD documents.
|
staticprivate |
|
private |
|
private |
|
private |