org.fourthline.cling.protocol.async

## Class ReceivingSearch

- java.lang.Object
- - org.fourthline.cling.protocol.ReceivingAsync<IncomingSearchRequest>
  - - org.fourthline.cling.protocol.async.ReceivingSearch

- All Implemented Interfaces:
    Runnable

      public class ReceivingSearch
      extends ReceivingAsync<IncomingSearchRequest>

  Handles reception of search requests, responds for local registered devices.

  Waits a random time between 0 and the requested MX (maximum 120 seconds) before executing. Only waits if there are actually any registered local devices.

  Extracts the search target, builds and sends the dozens of messages required by the UPnP specification, depending on the search target and what local devices and services are found in the `Registry`.

  Author:
    Christian Bauer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Random` | `randomGenerator`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReceivingSearch(UpnpService upnpService, IncomingDatagramMessage<UpnpRequest> inputMessage)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected List<OutgoingSearchResponse>` | `createDeviceMessages(LocalDevice device, NetworkAddress activeStreamServer)`
    `protected List<OutgoingSearchResponse>` | `createServiceTypeMessages(LocalDevice device, NetworkAddress activeStreamServer)`
    `protected void` | `execute()`
    `protected Location` | `getDescriptorLocation(NetworkAddress activeStreamServer, LocalDevice device)`
    `protected boolean` | `isAdvertisementDisabled(LocalDevice device)`
    `protected void` | `prepareOutgoingSearchResponse(OutgoingSearchResponse message)` Override this to edit the outgoing message, e.g.
    `protected void` | `sendResponses(UpnpHeader searchTarget, NetworkAddress activeStreamServer)`
    `protected void` | `sendSearchResponseAll(NetworkAddress activeStreamServer)`
    `protected void` | `sendSearchResponseDeviceType(DeviceType deviceType, NetworkAddress activeStreamServer)`
    `protected void` | `sendSearchResponseRootDevices(NetworkAddress activeStreamServer)`
    `protected void` | `sendSearchResponseServiceType(ServiceType serviceType, NetworkAddress activeStreamServer)`
    `protected void` | `sendSearchResponseUDN(UDN udn, NetworkAddress activeStreamServer)`
    `protected boolean` | `waitBeforeExecution()` Provides an opportunity to pause before executing the protocol.

    - ### Methods inherited from class org.fourthline.cling.protocol.ReceivingAsync

      `getFirstHeader, getInputMessage, getUpnpService, run, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### randomGenerator

          protected final Random randomGenerator

  - ### Constructor Detail

    - #### ReceivingSearch

          public ReceivingSearch(UpnpService upnpService,
                                 IncomingDatagramMessage<UpnpRequest> inputMessage)

  - ### Method Detail

    - #### execute

          protected void execute()
                          throws RouterException

      Specified by:
        `execute` in class `ReceivingAsync<IncomingSearchRequest>`
      Throws:
        `RouterException`

    - #### waitBeforeExecution

          protected boolean waitBeforeExecution()
                                         throws InterruptedException

      Description copied from class: `ReceivingAsync`
      Provides an opportunity to pause before executing the protocol.
      Overrides:
        `waitBeforeExecution` in class `ReceivingAsync<IncomingSearchRequest>`
      Returns:
        `true` (default) if execution should continue after waiting.
      Throws:
        `InterruptedException` - If waiting has been interrupted, which also stops execution.

    - #### sendResponses

          protected void sendResponses(UpnpHeader searchTarget,
                                       NetworkAddress activeStreamServer)
                                throws RouterException

      Throws:
        `RouterException`

    - #### sendSearchResponseAll

          protected void sendSearchResponseAll(NetworkAddress activeStreamServer)
                                        throws RouterException

      Throws:
        `RouterException`

    - #### createDeviceMessages

          protected List<OutgoingSearchResponse> createDeviceMessages(LocalDevice device,
                                                                      NetworkAddress activeStreamServer)

    - #### createServiceTypeMessages

          protected List<OutgoingSearchResponse> createServiceTypeMessages(LocalDevice device,
                                                                           NetworkAddress activeStreamServer)

    - #### sendSearchResponseRootDevices

          protected void sendSearchResponseRootDevices(NetworkAddress activeStreamServer)
                                                throws RouterException

      Throws:
        `RouterException`

    - #### sendSearchResponseUDN

          protected void sendSearchResponseUDN(UDN udn,
                                               NetworkAddress activeStreamServer)
                                        throws RouterException

      Throws:
        `RouterException`

    - #### sendSearchResponseDeviceType

          protected void sendSearchResponseDeviceType(DeviceType deviceType,
                                                      NetworkAddress activeStreamServer)
                                               throws RouterException

      Throws:
        `RouterException`

    - #### sendSearchResponseServiceType

          protected void sendSearchResponseServiceType(ServiceType serviceType,
                                                       NetworkAddress activeStreamServer)
                                                throws RouterException

      Throws:
        `RouterException`

    - #### getDescriptorLocation

          protected Location getDescriptorLocation(NetworkAddress activeStreamServer,
                                                   LocalDevice device)

    - #### isAdvertisementDisabled

          protected boolean isAdvertisementDisabled(LocalDevice device)

    - #### prepareOutgoingSearchResponse

          protected void prepareOutgoingSearchResponse(OutgoingSearchResponse message)

      Override this to edit the outgoing message, e.g. by adding headers.

Copyright © 2016 4th Line GmbH, Switzerland. All rights reserved.