de.hfu.anybeam.networkCore

## Class DataReceiver

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

- All Implemented Interfaces:
    java.lang.Runnable

      public class DataReceiver
      extends java.lang.Object
      implements java.lang.Runnable

  Representing a mini server listening to the given port for incoming connection. For every connection a `DataReceiverConnection` object is used to handle the incoming data.
  Since:
    1.0
  Version:
    1.0
  Author:
    chrwuer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataReceiver(EncryptionType encryptionType, byte[] encrpytionKey, int port, DataReceiverAdapter adapter)` Creates a new `DataReceiver` instance using the given information.
    `DataReceiver(NetworkEnvironmentSettings settings, DataReceiverAdapter adapter)` Creates a new `DataReceiver` instance using the given `NetworkEnvironmentSettings`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `dispose()` Disposes this object and immediately stops all Threads and ongoing transmissions.
    `void` | `run()`

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

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

- - ### Constructor Detail

    - #### DataReceiver

          public DataReceiver(NetworkEnvironmentSettings settings,
                      DataReceiverAdapter adapter)
                       throws java.io.IOException

      Creates a new `DataReceiver` instance using the given `NetworkEnvironmentSettings`.
      Parameters:
        `settings` - the `NetworkEnvironmentSettings` to get all encessary information from
        `adapter` - the adapter to be notified about events
      Throws:
        `java.io.IOException`

    - #### DataReceiver

          public DataReceiver(EncryptionType encryptionType,
                      byte[] encrpytionKey,
                      int port,
                      DataReceiverAdapter adapter)
                       throws java.io.IOException

      Creates a new `DataReceiver` instance using the given information.
      Parameters:
        `encryptionType` - the `EncryptionType` to be used
        `encrpytionKey` - the encryption key to be used
        `port` - the port to wait for incoming connections on
        `adapter` - the adapter to be notified about events
      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### dispose

          public void dispose()

      Disposes this object and immediately stops all Threads and ongoing transmissions. The `ServerSocket` used by this object will be closed and the port is reusable.

    - #### run

          public void run()

      Specified by:
        `run` in interface `java.lang.Runnable`