Pipes and custom streams¶
The ImebraPipe class can be used to provide custom streams for the ACSE and DIMSE services.
A separate thread must be used to feed a ImebraPipe (to supply a custom reading stream) or to sink data from a ImebraPipe (to provide a custom writing stream).
ImebraPipe: public ImebraBaseStreamInputOutput¶
A pipe can be used to push and pull data to/from an Imebra codec.
This is useful when an Imebra codec must be used with a data source or a data sink not supported by the library (e.g. a TLS stream).
In order to allow Imebra to read data from a custom data source:
- allocate a ImebraPipe class and use it as parameter for the ImebraStreamReader needed by the codec
- from a secondary thread feed the data to the data source by calling feed()
In order to allow Imebra to write data to a custom data source:
- allocate a ImebraPipe class and use it as parameter for the ImebraStreamWriter needed by the codec
- from a secondary thread read the data to feed to the data sink by calling sink()
id ImebraPipe::initWithBufferSize:(unsigned int circularBufferSize)
circularBufferSize: the size of the buffer that stores the data fed to the Pipe until it is fetched
void ImebraPipe::feed:error:(ImebraReadMemory * buffer, (swift_error(nonnull_error)) __attribute__)
Copy data into the Pipe so it can be retrieved by a codec via a StreamReader.
buffer: the data to copy into the Pipe’s buffer
unsigned int ImebraPipe::sink:error:(ImebraReadWriteMemory * buffer, (swift_error(nonnull_error)) __attribute__)
Read data from the Pipe. The data can be pushed into the pipe via a StreamWriter.
- the number of bytes read from the pipe, which may be less than the buffer’s size
buffer: a buffer that will contain the read data. The method will try to read as many bytes as the buffer size
void ImebraPipe::close:error:(unsigned int timeoutMilliseconds, (swift_error(nonnull_error)) __attribute__)
Wait for the specified amount of time or until the internal buffer is empty (all the data fed has been retrieved by the StreamReader or by sink()), whichever comes first, then call terminate.
Subsequent read and write operations will fail by throwing the exception StreamClosedError.
timeoutMilliseconds: the maximum time to wait until the internal buffer is empty, in milliseconds
Instruct any pending operation to terminate.
Current and subsequent read and write operations will fail by setting pError to ImebraStreamClosedError.