@Override protected boolean waitBeforeExecution() throws InterruptedException { Integer mx = getInputMessage().getMX(); if (mx == null) { log.fine("Invalid search request, did not contain MX header: " + getInputMessage()); return false; } // Spec says we should assume "less" if it's 120 or more // From the spec, MX should be "greater than or equal to 1" // Prevent negative MX to make nextInt() throw IllegalArgumentException below if (mx > 120 || mx <= 0) mx = MXHeader.DEFAULT_VALUE; // Only wait if there is something to wait for if (getUpnpService().getRegistry().getLocalDevices().size() > 0) { int sleepTime = randomGenerator.nextInt(mx * 1000); log.fine("Sleeping " + sleepTime + " milliseconds to avoid flooding with search responses"); Thread.sleep(sleepTime); } return true; }
protected void sendSearchResponseRootDevices(NetworkAddress activeStreamServer) throws RouterException { log.fine("Responding to root device search with advertisement messages for all local root devices"); for (LocalDevice device : getUpnpService().getRegistry().getLocalDevices()) { if (isAdvertisementDisabled(device)) continue; OutgoingSearchResponse message = new OutgoingSearchResponseRootDevice( getInputMessage(), getDescriptorLocation(activeStreamServer, device), device ); prepareOutgoingSearchResponse(message); getUpnpService().getRouter().send(message); } }
log.fine("Responding to 'all' search with advertisement messages for all local devices"); for (LocalDevice localDevice : getUpnpService().getRegistry().getLocalDevices()) {
@Override protected boolean waitBeforeExecution() throws InterruptedException { Integer mx = getInputMessage().getMX(); if (mx == null) { log.fine("Invalid search request, did not contain MX header: " + getInputMessage()); return false; } // Spec says we should assume "less" if it's 120 or more // From the spec, MX should be "greater than or equal to 1" // Prevent negative MX to make nextInt() throw IllegalArgumentException below if (mx > 120 || mx <= 0) mx = MXHeader.DEFAULT_VALUE; // Only wait if there is something to wait for if (getUpnpService().getRegistry().getLocalDevices().size() > 0) { int sleepTime = randomGenerator.nextInt(mx * 1000); log.fine("Sleeping " + sleepTime + " milliseconds to avoid flooding with search responses"); Thread.sleep(sleepTime); } return true; }
protected void sendSearchResponseRootDevices(NetworkAddress activeStreamServer) throws RouterException { log.fine("Responding to root device search with advertisement messages for all local root devices"); for (LocalDevice device : getUpnpService().getRegistry().getLocalDevices()) { if (isAdvertisementDisabled(device)) continue; OutgoingSearchResponse message = new OutgoingSearchResponseRootDevice( getInputMessage(), getDescriptorLocation(activeStreamServer, device), device ); prepareOutgoingSearchResponse(message); getUpnpService().getRouter().send(message); } }
protected void sendSearchResponseAll(NetworkAddress activeStreamServer) throws RouterException { log.fine("Responding to 'all' search with advertisement messages for all local devices"); for (LocalDevice localDevice : getUpnpService().getRegistry().getLocalDevices()) {
@Override protected boolean waitBeforeExecution() throws InterruptedException { Integer mx = getInputMessage().getMX(); if (mx == null) { log.fine("Invalid search request, did not contain MX header: " + getInputMessage()); return false; } // Spec says we should assume "less" if it's 120 or more // From the spec, MX should be "greater than or equal to 1" // Prevent negative MX to make nextInt() throw IllegalArgumentException below if (mx > 120 || mx <= 0) mx = MXHeader.DEFAULT_VALUE; // Only wait if there is something to wait for if (getUpnpService().getRegistry().getLocalDevices().size() > 0) { int sleepTime = randomGenerator.nextInt(mx * 1000); log.fine("Sleeping " + sleepTime + " milliseconds to avoid flooding with search responses"); Thread.sleep(sleepTime); } return true; }
protected void sendSearchResponseRootDevices(NetworkAddress activeStreamServer) throws RouterException { log.fine("Responding to root device search with advertisement messages for all local root devices"); for (LocalDevice device : getUpnpService().getRegistry().getLocalDevices()) { if (isAdvertisementDisabled(device)) continue; OutgoingSearchResponse message = new OutgoingSearchResponseRootDevice( getInputMessage(), getDescriptorLocation(activeStreamServer, device), device ); prepareOutgoingSearchResponse(message); getUpnpService().getRouter().send(message); } }
log.fine("Responding to 'all' search with advertisement messages for all local devices"); for (LocalDevice localDevice : getUpnpService().getRegistry().getLocalDevices()) {