org.fourthline.cling.protocol.async
Class ReceivingSearch

java.lang.Object
  extended by org.fourthline.cling.protocol.ReceivingAsync<IncomingSearchRequest>
      extended by 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
protected  Random randomGenerator
           
 
Constructor Summary
ReceivingSearch(UpnpService upnpService, IncomingDatagramMessage<UpnpRequest> inputMessage)
           
 
Method Summary
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()
Specified by:
execute in class ReceivingAsync<IncomingSearchRequest>

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)

sendSearchResponseAll

protected void sendSearchResponseAll(NetworkAddress activeStreamServer)

createDeviceMessages

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

createServiceTypeMessages

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

sendSearchResponseRootDevices

protected void sendSearchResponseRootDevices(NetworkAddress activeStreamServer)

sendSearchResponseUDN

protected void sendSearchResponseUDN(UDN udn,
                                     NetworkAddress activeStreamServer)

sendSearchResponseDeviceType

protected void sendSearchResponseDeviceType(DeviceType deviceType,
                                            NetworkAddress activeStreamServer)

sendSearchResponseServiceType

protected void sendSearchResponseServiceType(ServiceType serviceType,
                                             NetworkAddress activeStreamServer)

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 © 2013 4th Line GmbH, Switzerland. All Rights Reserved.