public interface Stream
An implementation doesn't need to be thread-safe. All methods are expected to execute quickly.
Modifier and Type | Method and Description |
---|---|
void |
flush()
Flushes any internally buffered messages to the remote end-point.
|
boolean |
isReady()
If
true , indicates that the transport is capable of sending additional messages
without requiring excessive buffering internally. |
void |
request(int numMessages)
Requests up to the given number of messages from the call to be delivered to
StreamListener.messageRead(java.io.InputStream) . |
void |
writeMessage(InputStream message)
Writes a message payload to the remote end-point.
|
void request(int numMessages)
StreamListener.messageRead(java.io.InputStream)
. No additional messages will be
delivered.numMessages
- the requested number of messages to be delivered to the listener.void writeMessage(InputStream message)
KnownLength
to improve efficiency. This method will always return immediately
and will not wait for the write to complete.
When the write is "accepted" by the transport, the given callback (if provided) will be called. The definition of what it means to be "accepted" is up to the transport implementation, but this is a general indication that the transport is capable of handling more out-bound data on the stream. If the stream/connection is closed for any reason before the write could be accepted, the callback will never be invoked.
message
- stream containing the serialized message to be sentvoid flush()
boolean isReady()
true
, indicates that the transport is capable of sending additional messages
without requiring excessive buffering internally. This event is
just a suggestion and the application is free to ignore it, however doing so may
result in excessive buffering within the transport.