use of org.fourthline.cling.UpnpService in project libresonic by Libresonic.
the class ClingRouter method findConnectionService.
/**
* Returns the UPnP service used for port mapping.
*/
private static Service findConnectionService(UpnpService upnpService) {
class ConnectionServiceDiscoverer extends PortMappingListener {
ConnectionServiceDiscoverer() {
super(new PortMapping[0]);
}
@Override
public Service discoverConnectionService(Device device) {
return super.discoverConnectionService(device);
}
}
ConnectionServiceDiscoverer discoverer = new ConnectionServiceDiscoverer();
Collection<Device> devices = upnpService.getRegistry().getDevices();
for (Device device : devices) {
Service service = discoverer.discoverConnectionService(device);
if (service != null) {
return service;
}
}
return null;
}
use of org.fourthline.cling.UpnpService in project SmartApplianceEnabler by camueller.
the class SempDiscovery method run.
public void run() {
try {
final ExecutorService executorService = Executors.newSingleThreadExecutor();
final UpnpService upnpService = new UpnpServiceImpl(serviceConfiguration);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
upnpService.shutdown();
}
});
// Add the bound local device to the registry
upnpService.getRegistry().addDevice(createDevice());
} catch (Exception ex) {
System.err.println("Exception occured: " + ex);
ex.printStackTrace(System.err);
System.exit(1);
}
}
Aggregations