YAACC - UPNP Client and Server
|
Execute actions on any service. More...
Classes | |
class | Default |
Empty implementation of callback methods, simplifies synchronous execution of an org.fourthline.cling.model.action.ActionInvocation . | |
Public Member Functions | |
ActionInvocation | getActionInvocation () |
synchronized ControlPoint | getControlPoint () |
synchronized ActionCallback | setControlPoint (ControlPoint controlPoint) |
void | run () |
abstract void | success (ActionInvocation invocation) |
Called when the action invocation succeeded. | |
abstract void | failure (ActionInvocation invocation, UpnpResponse operation, String defaultMsg) |
Called when the action invocation failed. | |
String | toString () |
Protected Member Functions | |
ActionCallback (ActionInvocation actionInvocation, ControlPoint controlPoint) | |
ActionCallback (ActionInvocation actionInvocation) | |
String | createDefaultFailureMessage (ActionInvocation invocation, UpnpResponse operation) |
void | failure (ActionInvocation invocation, UpnpResponse operation) |
Protected Attributes | |
final ActionInvocation | actionInvocation |
ControlPoint | controlPoint |
Execute actions on any service.
Usage example for asynchronous execution in a background thread:
Service service = device.findService(new UDAServiceId("SwitchPower")); Action getStatusAction = service.getAction("GetStatus"); ActionInvocation getStatusInvocation = new ActionInvocation(getStatusAction); ActionCallback getStatusCallback = new ActionCallback(getStatusInvocation) { public void success(ActionInvocation invocation) { ActionArgumentValue status = invocation.getOutput("ResultStatus"); assertEquals((Boolean) status.getValue(), Boolean.valueOf(false)); } public void failure(ActionInvocation invocation, UpnpResponse res) { System.err.println( createDefaultFailureMessage(invocation, res) ); } }; upnpService.getControlPoint().execute(getStatusCallback)
<p<blockquote>
You can also execute the action synchronously in the same thread using the org.fourthline.cling.controlpoint.ActionCallback.Default
implementation:
myActionInvocation.setInput("foo", bar); new ActionCallback.Default(myActionInvocation, upnpService.getControlPoint()).run(); myActionInvocation.getOutput("baz");
|
abstract |
Called when the action invocation failed.
invocation | The failed invocation, call its getFailure() method for more details. |
operation | If the invocation was on a remote service, the response message, otherwise null. |
defaultMsg | A user-friendly error message generated from the invocation exception and response. |
|
abstract |
Called when the action invocation succeeded.
invocation | The successful invocation, call its getOutput() method for results. |