Package net.dona.doip.client.transport
Class DoipConnectionImpl
java.lang.Object
net.dona.doip.client.transport.DoipConnectionImpl
- All Implemented Interfaces:
AutoCloseable,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
ConstructorsConstructorDescriptionDoipConnectionImpl(Socket socket) Establishes a DoipConnection using the specified Socket. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanisClosed()Returns true if the connection is closed.sendCompactRequest(DoipRequestHeaders request) Sends a "compact" request consisting of a single JSON segment, with the request "input" embedded in the initial segment.sendRequest(DoipRequestHeaders request, InDoipMessage in) Sends a request with the specified initial segment, and subsequent segments (the request "input") read from the supplied InDoipMessage.sendRequestToExchange(DoipRequestHeaders request) Sends a request using a specified initial segment, and providing aDoipExchangewhich allows writing additional segments as well as reading segments from the response.
-
Constructor Details
-
DoipConnectionImpl
Establishes a DoipConnection using the specified Socket. Generally, instances of DoipConnection should be obtained using the methods ofTransportDoipClient.
-
-
Method Details
-
isClosed
public boolean isClosed()Description copied from interface:DoipConnectionReturns true if the connection is closed.- Specified by:
isClosedin interfaceDoipConnection- Returns:
- true if the connection is closed
-
sendCompactRequest
Description copied from interface:DoipConnectionSends a "compact" request consisting of a single JSON segment, with the request "input" embedded in the initial segment.- Specified by:
sendCompactRequestin interfaceDoipConnection- Parameters:
request- the single-segment "compact" request to be sent- Returns:
- the response
- Throws:
IOException
-
sendRequest
public DoipClientResponse sendRequest(DoipRequestHeaders request, InDoipMessage in) throws IOException Description copied from interface:DoipConnectionSends a request with the specified initial segment, and subsequent segments (the request "input") read from the supplied InDoipMessage.- Specified by:
sendRequestin interfaceDoipConnection- 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:
IOException
-
sendRequestToExchange
Description copied from interface:DoipConnectionSends a request using a specified initial segment, and providing aDoipExchangewhich allows writing additional segments as well as reading segments from the response.- Specified by:
sendRequestToExchangein interfaceDoipConnection- Parameters:
request- the initial segment of the request (except the requestId which will be generated automatically)- Returns:
- an instance of
DoipExchangewhich allows writing additional segments as well as reading segments from the response - Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDoipConnection
-