0

Is there a way to specify an @UpnpAction with no associated @UpnpStateVariable in Cling?. I tried something like

public class ApplicationExecutionServer {
    @UpnpAction    
    public void anAction() {
        // do something
    }
}

but got an error saying that the action "anAction" is not associated to an state variable.

Carlos Alegría
  • 374
  • 1
  • 3
  • 13

1 Answers1

0

Unfortunately, there is no way to have a 'headless' action. You CAN however have an inert variable. For example, I have a service like this which uses a supposed String setter to simulate an action that really doesn't involve a primitive state variable.

@UpnpStateVariable(defaultValue="0", sendEvents=false)
private String clientHandshakeData = null;


/**
 * "Headless" action with ephemeral/transient state variable.
 * @param handshakeData
 */
@UpnpAction
public void setClientHandshakeData(@UpnpInputArgument(name="NewClientHandshakeDataValue")String handshakeData){
    clientHandshakeData = handshakeData;
    processCurrentHandshakeData();
    clientHandshakeData = null;

}

Essentially 'clientHandshakeData' is ephemeral and I expect each call to have a new value (with new clients connecting). Each time a new one connects, I 'process' the current handshake data and immediately set it null.

Decoded
  • 1,057
  • 13
  • 17
  • NOTE: If you are running this in Multithreaded Environment, it might be good to have a 'synchronized' block in there as well, and have it block on an Object mutex, so that only one client can connect at a given time. Others will 'block' momentarily until the mutex is free. – Decoded Feb 26 '16 at 05:13