de.hfu.anybeam.networkCore

## Class DataSender

- java.lang.Object
- - java.lang.Thread
  - - de.hfu.anybeam.networkCore.AbstractTransmission
    - - de.hfu.anybeam.networkCore.DataSender

- All Implemented Interfaces:
    java.lang.Runnable

      public class DataSender
      extends AbstractTransmission

  Class to send a InputStream to a remote `DataReceiver`.
  Since:
    1.0
  Version:
    1.0
  Author:
    chrwuer

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataSender(java.io.InputStream inputStream, long inputStreamLength, java.lang.String inputName, EncryptionType encryptionType, byte[] encryptionKey, int receiverPort, java.net.InetAddress receiverAddress)` Creates a new `DataSender` instance.
    `DataSender(java.io.InputStream inputStream, long inputStreamLength, java.lang.String inputName, EncryptionType encryptionType, byte[] encryptionKey, int receiverPort, java.net.InetAddress receiverAddress, AbstractTransmissionAdapter adapter)` Creates a new `DataSender` instance.
    `DataSender(java.io.InputStream inputStream, long inputStreamLength, java.lang.String inputName, EncryptionType encryptionType, byte[] encryptionKey, int receiverPort, java.net.InetAddress receiverAddress, AbstractTransmissionAdapter adapter, java.lang.String senderClientId)`
    Creates a new `DataSender` instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `forceCloseTransmissionStream()` Closes all closable resources used by this `AbstractTransmission`.
    `void` | `transmit()` Transmits the data.

    - ### Methods inherited from class de.hfu.anybeam.networkCore.AbstractTransmission

      `cancelTransmission, getAveragSpeed, getResourceName, getTotalLength, getTransmissionId, getTransmittedLength, isCanceled, isDone, run, startTransmission`

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

      `activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

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

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

- - ### Constructor Detail

    - #### DataSender

          public DataSender(java.io.InputStream inputStream,
                    long inputStreamLength,
                    java.lang.String inputName,
                    EncryptionType encryptionType,
                    byte[] encryptionKey,
                    int receiverPort,
                    java.net.InetAddress receiverAddress)

      Creates a new `DataSender` instance.
      Parameters:
        `inputStream` - the `InputStream` to send
        `inputStreamLength` - the length of inputStream or -1 if the stream is endless
        `inputName` - the name of the resource represented by inputStream, e.g. the filename
        `encryptionType` - the `EncryptionType` that will be used
        `encryptionKey` - the encryption key that will be used
        `receiverPort` - the port on which the receiver is waiting
        `receiverAddress` - the `InetAddress` of the receiver

    - #### DataSender

          public DataSender(java.io.InputStream inputStream,
                    long inputStreamLength,
                    java.lang.String inputName,
                    EncryptionType encryptionType,
                    byte[] encryptionKey,
                    int receiverPort,
                    java.net.InetAddress receiverAddress,
                    AbstractTransmissionAdapter adapter)

      Creates a new `DataSender` instance.
      Parameters:
        `inputStream` - the `InputStream` to send
        `inputStreamLength` - the length of inputStream or -1 if the stream is endless
        `inputName` - the name of the resource represented by inputStream, e.g. the filename
        `encryptionType` - the `EncryptionType` that will be used
        `encryptionKey` - the encryption key that will be used
        `receiverPort` - the port on which the receiver is waiting
        `receiverAddress` - the `InetAddress` of the receiver
        `adapter` - the `AbstractTransmissionAdapter` to be notified about progress updates

    - #### DataSender

          public DataSender(java.io.InputStream inputStream,
                    long inputStreamLength,
                    java.lang.String inputName,
                    EncryptionType encryptionType,
                    byte[] encryptionKey,
                    int receiverPort,
                    java.net.InetAddress receiverAddress,
                    AbstractTransmissionAdapter adapter,
                    java.lang.String senderClientId)

      Creates a new `DataSender` instance.
      Parameters:
        `inputStream` - the `InputStream` to send
        `inputStreamLength` - the length of inputStream or -1 if the stream is endless
        `inputName` - the name of the resource represented by inputStream, e.g. the filename
        `encryptionType` - the `EncryptionType` that will be used
        `encryptionKey` - the encryption key that will be used
        `receiverPort` - the port on which the receiver is waiting
        `receiverAddress` - the `InetAddress` of the receiver
        `adapter` - the `AbstractTransmissionAdapter` to be notified about progress updates
        `senderClientId` - this device's client id to send to the receiver to identify this device

  - ### Method Detail

    - #### transmit

          public void transmit()
                        throws java.lang.Exception

      Description copied from class: `AbstractTransmission`
      Transmits the data. This method should call `AbstractTransmission.increaseTransmittedLength(long)` in fixed periods to allow precise speed and progress measurements.
      Throws:
        `java.lang.Exception`

    - #### forceCloseTransmissionStream

          public void forceCloseTransmissionStream()
                                            throws java.io.IOException

      Description copied from class: `AbstractTransmission`
      Closes all closable resources used by this `AbstractTransmission`. Is calles after a transmission is successfully done or in case of an error.
      Throws:
        `java.io.IOException`