public static interface RemoteEndpoint.Basic extends RemoteEndpoint
getSendStream
and
getSendWriter
which present traditional blocking I/O streams to
write messages.
If the websocket connection underlying this RemoteEndpoint is busy sending a message when a call is made to send
another one, for example if two threads attempt to call a send method concurrently, or if a developer attempts to
send a new message while in the middle of sending an existing one, the send method called while the connection is
already busy may throw an IllegalStateException
.
RemoteEndpoint.Async, RemoteEndpoint.Basic
Modifier and Type | Method and Description |
---|---|
java.io.OutputStream |
getSendStream()
Opens an output stream on which a binary message may be sent.
|
java.io.Writer |
getSendWriter()
Opens a character stream on which a text message may be sent.
|
void |
sendBinary(java.nio.ByteBuffer data)
Send a binary message, returning when all of the message has been transmitted.
|
void |
sendBinary(java.nio.ByteBuffer partialByte,
boolean isLast)
Send a binary message in parts, blocking until all of the message has been transmitted.
|
void |
sendObject(java.lang.Object data)
Sends a custom developer object, blocking until it has been transmitted.
|
void |
sendText(java.lang.String text)
Send a text message, blocking until all of the message has been transmitted.
|
void |
sendText(java.lang.String partialMessage,
boolean isLast)
Send a text message in parts, blocking until all of the message has been transmitted.
|
flushBatch, getBatchingAllowed, sendPing, sendPong, setBatchingAllowed
void sendText(java.lang.String text) throws java.io.IOException
text
- the message to be sent.java.io.IOException
- if there is a problem delivering the message.java.lang.IllegalArgumentException
- if the text is null
.void sendBinary(java.nio.ByteBuffer data) throws java.io.IOException
It is not safe for other threads to use the ByteBuffer until the sending of this message is complete. If the sending of the message completes successfully, the buffer's limit will be unchanged and the buffer's position will be equal to the limit. If the sending of the message does not complete successfully, the state of the buffer is undefined.
data
- the message to be sent.java.io.IOException
- if there is a problem delivering the message.java.lang.IllegalArgumentException
- if the data is null
.void sendText(java.lang.String partialMessage, boolean isLast) throws java.io.IOException
partialMessage
- the parts of the message being sent.isLast
- Whether the partial message being sent is the last part of the message.java.io.IOException
- if there is a problem delivering the message fragment.java.lang.IllegalArgumentException
- if the partialMessage is null
.void sendBinary(java.nio.ByteBuffer partialByte, boolean isLast) throws java.io.IOException
It is not safe for other threads to use the ByteBuffer until the sending of this partial message is complete. If the sending of the partial message completes successfully, the buffer's limit will be unchanged and the buffer's position will be equal to the limit. If the sending of the partial message does not complete successfully, the state of the buffer is undefined.
partialByte
- the part of the message being sent.isLast
- Whether the partial message being sent is the last part of the message.java.io.IOException
- if there is a problem delivering the partial message.java.lang.IllegalArgumentException
- if the partialByte is null
.java.io.OutputStream getSendStream() throws java.io.IOException
write()
methods before the output stream is closed then no WebSocket binary messages will
be sent. If at least one call is made to one of the write()
methods before the output stream is
closed then at least one WebSocket binary message will be sent even if that message is of zero length.java.io.IOException
- if there is a problem obtaining the OutputStream to write the binary message.java.io.Writer getSendWriter() throws java.io.IOException
write()
or append()
methods before the writer is closed then no WebSocket text messages
will be sent. If at least one call is made to one of the write()
or append()
methods before
the writer is closed then at least one WebSocket text message will be sent even if that message is of zero
length.java.io.IOException
- if there is a problem obtaining the Writer to write the text message.void sendObject(java.lang.Object data) throws java.io.IOException, EncodeException
data
- the object to be sent.java.io.IOException
- if there is a communication error sending the message object.EncodeException
- if there was a problem encoding the message object into the form of a native
websocket message.java.lang.IllegalArgumentException
- if the data parameter is null