public abstract class AbstractStream extends Object implements Stream
Modifier and Type | Class and Description |
---|---|
static class |
AbstractStream.TransportState
Stream state as used by the transport.
|
Constructor and Description |
---|
AbstractStream() |
Modifier and Type | Method and Description |
---|---|
protected void |
endOfMessages()
Closes the underlying framer.
|
void |
flush()
Flushes any internally buffered messages to the remote end-point.
|
protected abstract Framer |
framer()
The framer to use for sending messages.
|
boolean |
isReady()
If
true , indicates that the transport is capable of sending additional messages without
requiring excessive buffering internally. |
protected void |
onSendingBytes(int numBytes)
Event handler to be called by the subclass when a number of bytes are being queued for sending
to the remote endpoint.
|
void |
setCompressor(Compressor compressor)
Sets the compressor on the framer.
|
void |
setMessageCompression(boolean enable)
Enables per-message compression, if an encoding type has been negotiated.
|
protected abstract AbstractStream.TransportState |
transportState()
Obtain the transport state corresponding to this stream.
|
void |
writeMessage(InputStream message)
Writes a message payload to the remote end-point.
|
protected abstract Framer framer()
protected abstract AbstractStream.TransportState transportState()
public final void setMessageCompression(boolean enable)
Stream
setMessageCompression
in interface Stream
public final void writeMessage(InputStream message)
Stream
KnownLength
to improve efficiency. This method will always return immediately
and will not wait for the write to complete. If the stream has a start()
method, it
must be called before writing any messages.
It is recommended that the caller consult Stream.isReady()
before calling this method to
avoid excessive buffering in the transport.
This method takes ownership of the InputStream, and implementations are responsible for
calling InputStream.close()
.
writeMessage
in interface Stream
message
- stream containing the serialized message to be sentpublic final void flush()
Stream
protected final void endOfMessages()
public final void setCompressor(Compressor compressor)
Stream
setCompressor
in interface Stream
compressor
- the compressor to usepublic boolean isReady()
Stream
true
, indicates that the transport is capable of sending additional messages without
requiring excessive buffering internally. Otherwise, StreamListener.onReady()
will be
called when it turns true
.
This is just a suggestion and the application is free to ignore it, however doing so may result in excessive buffering within the transport.
protected final void onSendingBytes(int numBytes)
numBytes
- the number of bytes being sent.Copyright © 2018. All rights reserved.