org.fourthline.cling.protocol

## Class ReceivingAsync<M extends UpnpMessage>

- java.lang.Object
- - org.fourthline.cling.protocol.ReceivingAsync<M>

- Type Parameters:
    `M` - The type of UPnP message handled by this protocol.
  All Implemented Interfaces:
    Runnable
  Direct Known Subclasses:
    ReceivingNotification, ReceivingSearch, ReceivingSearchResponse, ReceivingSync

      public abstract class ReceivingAsync<M extends UpnpMessage>
      extends Object
      implements Runnable

  Supertype for all asynchronously executing protocols, handling reception of UPnP messages.

  After instantiation by the `ProtocolFactory`, this protocol `run()`s and calls its own `waitBeforeExecution()` method. By default, the protocol does not wait before then proceeding with `execute()`.

  Author:
    Christian Bauer

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ReceivingAsync(UpnpService upnpService, M inputMessage)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `execute()`
    `protected <H extends UpnpHeader> H` | `getFirstHeader(UpnpHeader.Type headerType, Class<H> subtype)`
    `M` | `getInputMessage()`
    `UpnpService` | `getUpnpService()`
    `void` | `run()`
    `String` | `toString()`
    `protected boolean` | `waitBeforeExecution()` Provides an opportunity to pause before executing the protocol.

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

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

- - ### Constructor Detail

    - #### ReceivingAsync

          protected ReceivingAsync(UpnpService upnpService,
                        M inputMessage)

  - ### Method Detail

    - #### getUpnpService

          public UpnpService getUpnpService()

    - #### getInputMessage

          public M getInputMessage()

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`

    - #### waitBeforeExecution

          protected boolean waitBeforeExecution()
                                         throws InterruptedException

      Provides an opportunity to pause before executing the protocol.
      Returns:
        `true` (default) if execution should continue after waiting.
      Throws:
        `InterruptedException` - If waiting has been interrupted, which also stops execution.

    - #### execute

          protected abstract void execute()
                                   throws RouterException

      Throws:
        `RouterException`

    - #### getFirstHeader

          protected <H extends UpnpHeader> H getFirstHeader(UpnpHeader.Type headerType,
                                                Class<H> subtype)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2014 4th Line GmbH, Switzerland. All Rights Reserved.