de.hfu.anybeam.networkCore

## Class NetworkEnvironment

- java.lang.Object
- - de.hfu.anybeam.networkCore.NetworkEnvironment

-     public class NetworkEnvironment
      extends java.lang.Object

  Able to find counterparts in the local network.
  Since:
    1.0
  Version:
    1.0
  Author:
    chrwuer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static double` | `VERSION`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NetworkEnvironment(NetworkEnvironmentSettings settings)` Creates a new `NetworkEnvironment` instance using the given `NetworkEnvironmentSettings`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAllNetworkEnvironmentListeners(java.util.List<NetworkEnvironmentListener> listeners)` Adds all `NetworkEnvironmentListener`s contained in the given `List`.
    `void` | `addNetworkEnvironmentListener(NetworkEnvironmentListener l)` Adds the given `NetworkEnvironmentListener` to this `NetworkEnvironment`
    `void` | `cancelClientSearch()` Cancels the active client search.
    `void` | `clearClientList()` Removes all `Client`s from the list of reachable `Client`s.
    `void` | `dispatchEvent(java.lang.String methodName)` Invokes the method with the given name on all `NetworkEnvironmentListener` registered on this `NetworkEnvironment`
    `void` | `dispatchEvent(java.lang.String methodName, java.lang.Class<?>[] parameterTypes, java.lang.Object... parameters)` Invokes the method with the given name on all `NetworkEnvironmentListener` registered on this `NetworkEnvironment`
    `void` | `dispose()` Disposes this `NetworkEnvironment` and all its sub-tasks.
    `java.util.List<NetworkEnvironmentListener>` | `getAllNetworkEnvironmentListeners()` Returns a `List` containing all `NetworkEnvironmentListener`s currently installed on this `NetworkEnvironment`.
    `int` | `getClientCount()` Returns the number of currently available `Client`s.
    `Client` | `getClientForId(java.lang.String id)` Returns the `Client` with the given id or null if no `Client` has the requested id.
    `java.util.List<Client>` | `getClientList()` Returns a `List` containing all `Client`s currently available on this `NetworkEnvironment`.
    `NetworkEnvironmentListener` | `getNetworkEnvironmentListener(int index)` Return the `NetworkEnvironmentListener` with the given index.
    `int` | `getNetworkEnvironmentListenerCount()` Returns the number of `NetworkEnvironmentListener` currently installed on this `NetworkEnvironment`.
    `NetworkEnvironmentSettings` | `getNetworkEnvironmentSettings()` Returns the `NetworkEnvironmentSettings` used by this instance.
    `void` | `removeAllNetworkEnvironmentListener()` Removes all `NetworkEnvironmentListener`s currently installed on this `NetworkEnvironment`.
    `void` | `removeNetworkEnvironmentListener(NetworkEnvironmentListener l)` Removes the given `NetworkEnvironmentListener` from this `NetworkEnvironment`
    `void` | `startClientSearch()` Starts a active, "infinite" (365 day) search for `Client`s in the local network.
    `void` | `startClientSearch(long howLong, java.util.concurrent.TimeUnit unitHowLong)` Starts a active search for `Client`s in the local network.
    `void` | `startClientSearch(long howLong, java.util.concurrent.TimeUnit unitHowLong, long pause, java.util.concurrent.TimeUnit unitPause)` Starts a active search for `Client`s in the local network.

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

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

- - ### Field Detail

    - #### VERSION

          public static final double VERSION

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NetworkEnvironment

          public NetworkEnvironment(NetworkEnvironmentSettings settings)
                             throws java.lang.Exception

      Creates a new `NetworkEnvironment` instance using the given `NetworkEnvironmentSettings`.
      Parameters:
        `settings` - the `NetworkEnvironmentSettings` to use
      Throws:
        `java.lang.Exception`

  - ### Method Detail

    - #### getNetworkEnvironmentSettings

          public NetworkEnvironmentSettings getNetworkEnvironmentSettings()

      Returns the `NetworkEnvironmentSettings` used by this instance.
      Returns:
        the `NetworkEnvironmentSettings` used by this instance

    - #### dispose

          public void dispose()
                       throws java.lang.Exception

      Disposes this `NetworkEnvironment` and all its sub-tasks.
      Throws:
        `java.lang.Exception`

    - #### getClientList

          public java.util.List<Client> getClientList()

      Returns a `List` containing all `Client`s currently available on this `NetworkEnvironment`.
      Returns:
        a `List` containing all `Client`s currently available on this `NetworkEnvironment`

    - #### addNetworkEnvironmentListener

          public void addNetworkEnvironmentListener(NetworkEnvironmentListener l)

      Adds the given `NetworkEnvironmentListener` to this `NetworkEnvironment`
      Parameters:
        `l` - the `NetworkEnvironmentListener` to add

    - #### removeNetworkEnvironmentListener

          public void removeNetworkEnvironmentListener(NetworkEnvironmentListener l)

      Removes the given `NetworkEnvironmentListener` from this `NetworkEnvironment`
      Parameters:
        `l` - the `NetworkEnvironmentListener` to remove

    - #### getNetworkEnvironmentListenerCount

          public int getNetworkEnvironmentListenerCount()

      Returns the number of `NetworkEnvironmentListener` currently installed on this `NetworkEnvironment`.
      Returns:
        the number of `NetworkEnvironmentListener` currently installed on this `NetworkEnvironment`

    - #### getNetworkEnvironmentListener

          public NetworkEnvironmentListener getNetworkEnvironmentListener(int index)

      Return the `NetworkEnvironmentListener` with the given index.
      Parameters:
        `index` - the index of the requested `NetworkEnvironmentListener`
      Returns:
        the requested `NetworkEnvironmentListener` or null if the index is invalid.
      See Also:
        `getNetworkEnvironmentListenerCount()`

    - #### getAllNetworkEnvironmentListeners

          public java.util.List<NetworkEnvironmentListener> getAllNetworkEnvironmentListeners()

      Returns a `List` containing all `NetworkEnvironmentListener`s currently installed on this `NetworkEnvironment`.
      Returns:
        a `List` containing all `NetworkEnvironmentListener`s currently installed on this `NetworkEnvironment`

    - #### addAllNetworkEnvironmentListeners

          public void addAllNetworkEnvironmentListeners(java.util.List<NetworkEnvironmentListener> listeners)

      Adds all `NetworkEnvironmentListener`s contained in the given `List`.
      Parameters:
        `listeners` - all `NetworkEnvironmentListener` that sould be added

    - #### removeAllNetworkEnvironmentListener

          public void removeAllNetworkEnvironmentListener()

      Removes all `NetworkEnvironmentListener`s currently installed on this `NetworkEnvironment`.

    - #### getClientCount

          public int getClientCount()

      Returns the number of currently available `Client`s.
      Returns:
        the number of currently available `Client`s

    - #### getClientForId

          public Client getClientForId(java.lang.String id)

      Returns the `Client` with the given id or null if no `Client` has the requested id.
      Parameters:
        `id` - the id of the requested `Client`
      Returns:
        the `Client` with the given id or null if no `Client` has the requested id.

    - #### startClientSearch

          public void startClientSearch()

      Starts a active, "infinite" (365 day) search for `Client`s in the local network. Remember to cancel it, especially on mobile devices!
      See Also:
        `startClientSearch(long, TimeUnit)`, `startClientSearch(long, TimeUnit, long, TimeUnit)`

    - #### startClientSearch

          public void startClientSearch(long howLong,
                               java.util.concurrent.TimeUnit unitHowLong)

      Starts a active search for `Client`s in the local network. The search is automatically cancelled after the given time.
      Parameters:
        `howLong` - the duration of the search
        `unitHowLong` - the `TimeUnit` of howLong
      See Also:
        `startClientSearch()`, `startClientSearch(long, TimeUnit, long, TimeUnit)`

    - #### startClientSearch

          public void startClientSearch(long howLong,
                               java.util.concurrent.TimeUnit unitHowLong,
                               long pause,
                               java.util.concurrent.TimeUnit unitPause)

      Starts a active search for `Client`s in the local network. The search is automatically cancelled after the given time. The signals are send in the given interval.
      Parameters:
        `howLong` - the duration of the search
        `unitHowLong` - the `TimeUnit` of howLong
        `pause` - the time between the signals
        `unitPause` - the `TimeUnit` of pause
      See Also:
        `startClientSearch()`, `startClientSearch(long, TimeUnit, long, TimeUnit)`

    - #### cancelClientSearch

          public void cancelClientSearch()

      Cancels the active client search. Does nothing if no search is active.

    - #### clearClientList

          public void clearClientList()

      Removes all `Client`s from the list of reachable `Client`s.

    - #### dispatchEvent

          public void dispatchEvent(java.lang.String methodName)
                             throws java.lang.Exception

      Invokes the method with the given name on all `NetworkEnvironmentListener` registered on this `NetworkEnvironment`
      Parameters:
        `methodName` - the name of the method that should be invoked
      Throws:
        `java.lang.Exception`

    - #### dispatchEvent

          public void dispatchEvent(java.lang.String methodName,
                           java.lang.Class<?>[] parameterTypes,
                           java.lang.Object... parameters)
                             throws java.lang.Exception

      Invokes the method with the given name on all `NetworkEnvironmentListener` registered on this `NetworkEnvironment`
      Parameters:
        `methodName` - the name of the method that should be invoked
        `parameterTypes` - the list of parameters
        `parameters` - the parameter values
      Throws:
        `java.lang.Exception`