UPNP don't notify embedded child devices by default (#4735)
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>pull/4835/head
parent
5b12280f5b
commit
cce185af64
|
@ -79,4 +79,14 @@ public interface UpnpDiscoveryParticipant {
|
||||||
default long getRemovalGracePeriodSeconds(RemoteDevice device) {
|
default long getRemovalGracePeriodSeconds(RemoteDevice device) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The discovery always notifies participants about discovered root devices. And if the participant also
|
||||||
|
* wants to be notified about embedded child devices then it shall override this method.
|
||||||
|
*
|
||||||
|
* @return true if the participant wants to be also notified about embedded child devices.
|
||||||
|
*/
|
||||||
|
default boolean notifyChildDevices() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,9 @@ public class UpnpDiscoveryService extends AbstractDiscoveryService
|
||||||
|
|
||||||
Collection<RemoteDevice> devices = upnpService.getRegistry().getRemoteDevices();
|
Collection<RemoteDevice> devices = upnpService.getRegistry().getRemoteDevices();
|
||||||
for (RemoteDevice device : devices) {
|
for (RemoteDevice device : devices) {
|
||||||
|
if (!device.isRoot() && !participant.notifyChildDevices()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
DiscoveryResult result = participant.createResult(device);
|
DiscoveryResult result = participant.createResult(device);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
final DiscoveryResult resultNew = getLocalizedDiscoveryResult(result,
|
final DiscoveryResult resultNew = getLocalizedDiscoveryResult(result,
|
||||||
|
@ -171,6 +174,9 @@ public class UpnpDiscoveryService extends AbstractDiscoveryService
|
||||||
@Override
|
@Override
|
||||||
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
|
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
|
||||||
for (UpnpDiscoveryParticipant participant : participants) {
|
for (UpnpDiscoveryParticipant participant : participants) {
|
||||||
|
if (!device.isRoot() && !participant.notifyChildDevices()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
DiscoveryResult result = participant.createResult(device);
|
DiscoveryResult result = participant.createResult(device);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
@ -200,6 +206,9 @@ public class UpnpDiscoveryService extends AbstractDiscoveryService
|
||||||
@Override
|
@Override
|
||||||
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
|
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
|
||||||
for (UpnpDiscoveryParticipant participant : participants) {
|
for (UpnpDiscoveryParticipant participant : participants) {
|
||||||
|
if (!device.isRoot() && !participant.notifyChildDevices()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
ThingUID thingUID = participant.getThingUID(device);
|
ThingUID thingUID = participant.getThingUID(device);
|
||||||
if (thingUID != null) {
|
if (thingUID != null) {
|
||||||
|
|
Loading…
Reference in New Issue