YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
org.fourthline.cling.controlpoint.ActionCallback Class Referenceabstract

Execute actions on any service. More...

Inheritance diagram for org.fourthline.cling.controlpoint.ActionCallback:
Inheritance graph
Collaboration diagram for org.fourthline.cling.controlpoint.ActionCallback:
Collaboration graph

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
 

Detailed Description

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");
Author
Christian Bauer

Member Function Documentation

◆ failure()

abstract void org.fourthline.cling.controlpoint.ActionCallback.failure ( ActionInvocation  invocation,
UpnpResponse  operation,
String  defaultMsg 
)
abstract

Called when the action invocation failed.

Parameters
invocationThe failed invocation, call its getFailure() method for more details.
operationIf the invocation was on a remote service, the response message, otherwise null.
defaultMsgA user-friendly error message generated from the invocation exception and response.
See also
#createDefaultFailureMessage

◆ success()

abstract void org.fourthline.cling.controlpoint.ActionCallback.success ( ActionInvocation  invocation)
abstract

Called when the action invocation succeeded.

Parameters
invocationThe successful invocation, call its getOutput() method for results.

The documentation for this class was generated from the following file: