Package net.dona.doip.client.transport

## Class DoipConnectionImpl

- java.lang.Object
- - net.dona.doip.client.transport.DoipConnectionImpl

- All Implemented Interfaces:
    `java.lang.AutoCloseable`, `DoipConnection`

      public class DoipConnectionImpl
      extends java.lang.Object
      implements DoipConnection

  An implementation of `DoipConnection`. Generally, instances of DoipConnection should be obtained using the methods of `TransportDoipClient` or `DoipConnectionPool`. The user can send requests using the `sendCompactRequest(DoipRequestHeaders)`, `sendRequest(DoipRequestHeaders, InDoipMessage)`, and `sendRequestToExchange(DoipRequestHeaders)` methods. The user should call `close()` when done (except when obtained from a pool, in which case `DoipConnectionPool.release(DoipConnection)` should be called instead).

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DoipConnectionImpl​(java.net.Socket socket)` | Establishes a DoipConnection using the specified Socket.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` |
    `boolean` | `isClosed()` | Returns true if the connection is closed.
    `DoipClientResponse` | `sendCompactRequest​(DoipRequestHeaders request)` | Sends a "compact" request consisting of a single JSON segment, with the request "input" embedded in the initial segment.
    `DoipClientResponse` | `sendRequest​(DoipRequestHeaders request, InDoipMessage in)` | Sends a request with the specified initial segment, and subsequent segments (the request "input") read from the supplied InDoipMessage.
    `DoipExchange` | `sendRequestToExchange​(DoipRequestHeaders request)` | Sends a request using a specified initial segment, and providing a `DoipExchange` which allows writing additional segments as well as reading segments from the response.

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

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

- - ### Constructor Detail

    - #### DoipConnectionImpl

          public DoipConnectionImpl​(java.net.Socket socket)

      Establishes a DoipConnection using the specified Socket. Generally, instances of DoipConnection should be obtained using the methods of `TransportDoipClient`.
      Parameters:
        `socket` -

  - ### Method Detail

    - #### isClosed

          public boolean isClosed()

      Description copied from interface: `DoipConnection`
      Returns true if the connection is closed.
      Specified by:
        `isClosed` in interface `DoipConnection`
      Returns:
        true if the connection is closed

    - #### sendCompactRequest

          public DoipClientResponse sendCompactRequest​(DoipRequestHeaders request)
                                                throws java.io.IOException

      Description copied from interface: `DoipConnection`
      Sends a "compact" request consisting of a single JSON segment, with the request "input" embedded in the initial segment.
      Specified by:
        `sendCompactRequest` in interface `DoipConnection`
      Parameters:
        `request` - the single-segment "compact" request to be sent
      Returns:
        the response
      Throws:
        `java.io.IOException`

    - #### sendRequest

          public DoipClientResponse sendRequest​(DoipRequestHeaders request,
                                                InDoipMessage in)
                                         throws java.io.IOException

      Description copied from interface: `DoipConnection`
      Sends a request with the specified initial segment, and subsequent segments (the request "input") read from the supplied InDoipMessage.
      Specified by:
        `sendRequest` in interface `DoipConnection`
      Parameters:
        `request` - the initial segment of the request (except the requestId which will be generated automatically)
        `in` - the remaining segments of the request
      Returns:
        the response
      Throws:
        `java.io.IOException`

    - #### sendRequestToExchange

          public DoipExchange sendRequestToExchange​(DoipRequestHeaders request)
                                             throws java.io.IOException

      Description copied from interface: `DoipConnection`
      Sends a request using a specified initial segment, and providing a `DoipExchange` which allows writing additional segments as well as reading segments from the response.
      Specified by:
        `sendRequestToExchange` in interface `DoipConnection`
      Parameters:
        `request` - the initial segment of the request (except the requestId which will be generated automatically)
      Returns:
        an instance of `DoipExchange` which allows writing additional segments as well as reading segments from the response
      Throws:
        `java.io.IOException`

    - #### close

          public void close()

      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `DoipConnection`