use of org.fourthline.cling.support.igd.callback.PortMappingAdd in project libresonic by Libresonic.
the class ClingRouter method addPortMappingImpl.
private void addPortMappingImpl(Service connectionService, int port) throws Exception {
final Semaphore gotReply = new Semaphore(0);
final AtomicReference<String> error = new AtomicReference<String>();
upnpService.getControlPoint().execute(new PortMappingAdd(connectionService, createPortMapping(port)) {
@Override
public void success(ActionInvocation invocation) {
gotReply.release();
}
@Override
public void failure(ActionInvocation invocation, UpnpResponse response, String defaultMsg) {
error.set(String.valueOf(response) + ": " + defaultMsg);
gotReply.release();
}
});
gotReply.acquire();
if (error.get() != null) {
throw new Exception(error.get());
}
}
Aggregations