org.teleal.cling.protocol.async
Class ReceivingSearch

java.lang.Object
  extended by org.teleal.cling.protocol.ReceivingAsync<IncomingSearchRequest>
      extended by org.teleal.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)
           
protected  List<OutgoingSearchResponse> createServiceTypeMessages(LocalDevice device)
           
protected  void execute()
           
protected  Locator getDescriptorLocator(InetAddress bindingAddress, LocalDevice device)
           
protected  void sendResponses(UpnpHeader searchTarget)
           
protected  void sendSearchResponseAll()
           
protected  void sendSearchResponseDeviceType(DeviceType deviceType)
           
protected  void sendSearchResponseRootDevices()
           
protected  void sendSearchResponseServiceType(ServiceType serviceType)
           
protected  void sendSearchResponseUDN(UDN udn)
           
protected  boolean waitBeforeExecution()
          Provides an opportunity to pause before executing the protocol.
 
Methods inherited from class org.teleal.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)

sendSearchResponseAll

protected void sendSearchResponseAll()

createDeviceMessages

protected List<OutgoingSearchResponse> createDeviceMessages(LocalDevice device)

createServiceTypeMessages

protected List<OutgoingSearchResponse> createServiceTypeMessages(LocalDevice device)

sendSearchResponseRootDevices

protected void sendSearchResponseRootDevices()

sendSearchResponseUDN

protected void sendSearchResponseUDN(UDN udn)

sendSearchResponseDeviceType

protected void sendSearchResponseDeviceType(DeviceType deviceType)

sendSearchResponseServiceType

protected void sendSearchResponseServiceType(ServiceType serviceType)

getDescriptorLocator

protected Locator getDescriptorLocator(InetAddress bindingAddress,
                                       LocalDevice device)


Copyright © 2010 Teleal GmbH, Switzerland. All Rights Reserved.