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 |
---|---|
OutputStream |
getSendStream()
Opens an output stream on which a binary message may be sent.
|
Writer |
getSendWriter()
Opens an character stream on which a text message may be sent.
|
void |
sendBinary(ByteBuffer data)
Send a binary message, returning when all of the message has been transmitted.
|
void |
sendBinary(ByteBuffer partialByte,
boolean isLast)
Send a binary message in parts, blocking until all of the message has been transmitted.
|
void |
sendObject(Object data)
Sends a custom developer object, blocking until it has been transmitted.
|
void |
sendText(String text)
Send a text message, blocking until all of the message has been transmitted.
|
void |
sendText(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(String text) throws IOException
text
- the message to be sent.IOException
- if there is a problem delivering the message.IllegalArgumentException
- if the text is null
.void sendBinary(ByteBuffer data) throws IOException
data
- the message to be sent.IOException
- if there is a problem delivering the message.IllegalArgumentException
- if the data is null
.void sendText(String partialMessage, boolean isLast) throws IOException
partialMessage
- the parts of the message being sent.isLast
- Whether the partial message being sent is the last part of the message.IOException
- if there is a problem delivering the message fragment.IllegalArgumentException
- if the partialMessage is null
.void sendBinary(ByteBuffer partialByte, boolean isLast) throws IOException
partialByte
- the part of the message being sent.isLast
- Whether the partial message being sent is the last part of the message.IOException
- if there is a problem delivering the partial message.IllegalArgumentException
- if the partialByte is null
.OutputStream getSendStream() throws IOException
IOException
- if there is a problem obtaining the OutputStream to write the binary message.Writer getSendWriter() throws IOException
IOException
- if there is a problem obtaining the Writer to write the text message.void sendObject(Object data) throws IOException, EncodeException
data
- the object to be sent.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.IllegalArgumentException
- if the data parameter is null
Copyright © 1996-2017, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.