org.fourthline.cling.transport.impl

## Class MulticastReceiverImpl

- java.lang.Object
- - org.fourthline.cling.transport.impl.MulticastReceiverImpl

- All Implemented Interfaces:
    Runnable, MulticastReceiver<MulticastReceiverConfigurationImpl>

      public class MulticastReceiverImpl
      extends Object
      implements MulticastReceiver<MulticastReceiverConfigurationImpl>

  Default implementation based on a UDP `MulticastSocket`.

  Thread-safety is guaranteed through synchronization of methods of this service and by the thread-safe underlying socket.

  Author:
    Christian Bauer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected MulticastReceiverConfigurationImpl` | `configuration`
    `protected DatagramProcessor` | `datagramProcessor`
    `protected InetSocketAddress` | `multicastAddress`
    `protected NetworkInterface` | `multicastInterface`
    `protected NetworkAddressFactory` | `networkAddressFactory`
    `protected Router` | `router`
    `protected MulticastSocket` | `socket`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MulticastReceiverImpl(MulticastReceiverConfigurationImpl configuration)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `MulticastReceiverConfigurationImpl` | `getConfiguration()`
    `void` | `init(NetworkInterface networkInterface, Router router, NetworkAddressFactory networkAddressFactory, DatagramProcessor datagramProcessor)` Configures the service and starts any listening sockets.
    `void` | `run()`
    `void` | `stop()` Stops the service, closes any listening sockets.

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

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

- - ### Field Detail

    - #### configuration

          protected final MulticastReceiverConfigurationImpl configuration

    - #### router

          protected Router router

    - #### networkAddressFactory

          protected NetworkAddressFactory networkAddressFactory

    - #### datagramProcessor

          protected DatagramProcessor datagramProcessor

    - #### multicastInterface

          protected NetworkInterface multicastInterface

    - #### multicastAddress

          protected InetSocketAddress multicastAddress

    - #### socket

          protected MulticastSocket socket

  - ### Constructor Detail

    - #### MulticastReceiverImpl

          public MulticastReceiverImpl(MulticastReceiverConfigurationImpl configuration)

  - ### Method Detail

    - #### getConfiguration

          public MulticastReceiverConfigurationImpl getConfiguration()

      Specified by:
        `getConfiguration` in interface `MulticastReceiver<MulticastReceiverConfigurationImpl>`
      Returns:
        This service's configuration.

    - #### init

          public void init(NetworkInterface networkInterface,
                  Router router,
                  NetworkAddressFactory networkAddressFactory,
                  DatagramProcessor datagramProcessor)
                    throws InitializationException

      Description copied from interface: `MulticastReceiver`
      Configures the service and starts any listening sockets.
      Specified by:
        `init` in interface `MulticastReceiver<MulticastReceiverConfigurationImpl>`
      Parameters:
        `networkInterface` - The network interface on which to join the multicast group on.
        `router` - The router which handles received `IncomingDatagramMessage`s.
        `networkAddressFactory` - The network address factory to use for local address lookup given a local interface and a remote address.
        `datagramProcessor` - Reads and writes datagrams.
      Throws:
        `InitializationException` - If the service could not be initialized or started.

    - #### stop

          public void stop()

      Description copied from interface: `MulticastReceiver`
      Stops the service, closes any listening sockets.
      Specified by:
        `stop` in interface `MulticastReceiver<MulticastReceiverConfigurationImpl>`

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`

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