Package org.eclipse.jetty.websocket.api
Interface RemoteEndpoint
-
- All Known Implementing Classes:
WebSocketRemoteEndpoint
public interface RemoteEndpoint
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidflush()Flushes messages that may have been batched by the implementation.BatchModegetBatchMode()java.net.InetSocketAddressgetInetSocketAddress()Get the InetSocketAddress for the established connection.intgetMaxOutgoingFrames()Get the maximum number of data frames allowed to be waiting to be sent at any one time.voidsendBytes(java.nio.ByteBuffer data)Send a binary message, returning when all bytes of the message has been transmitted.voidsendBytes(java.nio.ByteBuffer data, WriteCallback callback)Initiates the asynchronous transmission of a binary message.java.util.concurrent.Future<java.lang.Void>sendBytesByFuture(java.nio.ByteBuffer data)Initiates the asynchronous transmission of a binary message.voidsendPartialBytes(java.nio.ByteBuffer fragment, boolean isLast)Send a binary message in pieces, blocking until all of the message has been transmitted.voidsendPartialString(java.lang.String fragment, boolean isLast)Send a text message in pieces, blocking until all of the message has been transmitted.voidsendPing(java.nio.ByteBuffer applicationData)Send a Ping message containing the given application data to the remote endpoint.voidsendPong(java.nio.ByteBuffer applicationData)Allows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session.voidsendString(java.lang.String text)Send a text message, blocking until all bytes of the message has been transmitted.voidsendString(java.lang.String text, WriteCallback callback)Initiates the asynchronous transmission of a text message.java.util.concurrent.Future<java.lang.Void>sendStringByFuture(java.lang.String text)Initiates the asynchronous transmission of a text message.voidsetBatchMode(BatchMode mode)Set the batch mode with which messages are sent.voidsetMaxOutgoingFrames(int maxOutgoingFrames)Set the maximum number of data frames allowed to be waiting to be sent at any one time.
-
-
-
Method Detail
-
sendBytes
void sendBytes(java.nio.ByteBuffer data) throws java.io.IOExceptionSend a binary message, returning when all bytes of the message has been transmitted.Note: this is a blocking call
- Parameters:
data- the message to be sent- Throws:
java.io.IOException- if unable to send the bytes
-
sendBytesByFuture
java.util.concurrent.Future<java.lang.Void> sendBytesByFuture(java.nio.ByteBuffer data)
Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted. Developers may use the returned Future object to track progress of the transmission.- Parameters:
data- the data being sent- Returns:
- the Future object representing the send operation.
-
sendBytes
void sendBytes(java.nio.ByteBuffer data, WriteCallback callback)Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted. Developers may provide a callback to be notified when the message has been transmitted or resulted in an error.- Parameters:
data- the data being sentcallback- callback to notify of success or failure of the write operation
-
sendPartialBytes
void sendPartialBytes(java.nio.ByteBuffer fragment, boolean isLast) throws java.io.IOExceptionSend a binary message in pieces, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final pieces are sent with isLast set to false. The final piece must be sent with isLast set to true.- Parameters:
fragment- the piece of the message being sentisLast- true if this is the last piece of the partial bytes- Throws:
java.io.IOException- if unable to send the partial bytes
-
sendPartialString
void sendPartialString(java.lang.String fragment, boolean isLast) throws java.io.IOExceptionSend a text message in pieces, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final pieces are sent with isLast set to false. The final piece must be sent with isLast set to true.- Parameters:
fragment- the piece of the message being sentisLast- true if this is the last piece of the partial bytes- Throws:
java.io.IOException- if unable to send the partial bytes
-
sendPing
void sendPing(java.nio.ByteBuffer applicationData) throws java.io.IOExceptionSend a Ping message containing the given application data to the remote endpoint. The corresponding Pong message may be picked up using the MessageHandler.Pong handler.- Parameters:
applicationData- the data to be carried in the ping request- Throws:
java.io.IOException- if unable to send the ping
-
sendPong
void sendPong(java.nio.ByteBuffer applicationData) throws java.io.IOExceptionAllows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session.- Parameters:
applicationData- the application data to be carried in the pong response.- Throws:
java.io.IOException- if unable to send the pong
-
sendString
void sendString(java.lang.String text) throws java.io.IOExceptionSend a text message, blocking until all bytes of the message has been transmitted.Note: this is a blocking call
- Parameters:
text- the message to be sent- Throws:
java.io.IOException- if unable to send the text message
-
sendStringByFuture
java.util.concurrent.Future<java.lang.Void> sendStringByFuture(java.lang.String text)
Initiates the asynchronous transmission of a text message. This method may return before the message is transmitted. Developers may use the returned Future object to track progress of the transmission.- Parameters:
text- the text being sent- Returns:
- the Future object representing the send operation.
-
sendString
void sendString(java.lang.String text, WriteCallback callback)Initiates the asynchronous transmission of a text message. This method may return before the message is transmitted. Developers may provide a callback to be notified when the message has been transmitted or resulted in an error.- Parameters:
text- the text being sentcallback- callback to notify of success or failure of the write operation
-
getBatchMode
BatchMode getBatchMode()
- Returns:
- the batch mode with which messages are sent.
- See Also:
flush()
-
setBatchMode
void setBatchMode(BatchMode mode)
Set the batch mode with which messages are sent.- Parameters:
mode- the batch mode to use- See Also:
flush()
-
getMaxOutgoingFrames
int getMaxOutgoingFrames()
Get the maximum number of data frames allowed to be waiting to be sent at any one time. The default value is -1, this indicates there is no limit on how many frames can be queued to be sent by the implementation. If the limit is exceeded, subsequent frames sent are failed with aWritePendingExceptionbut the connection is not failed and will remain open.- Returns:
- the max number of frames.
-
setMaxOutgoingFrames
void setMaxOutgoingFrames(int maxOutgoingFrames)
Set the maximum number of data frames allowed to be waiting to be sent at any one time. The default value is -1, this indicates there is no limit on how many frames can be queued to be sent by the implementation. If the limit is exceeded, subsequent frames sent are failed with aWritePendingExceptionbut the connection is not failed and will remain open.- Parameters:
maxOutgoingFrames- the max number of frames.
-
getInetSocketAddress
java.net.InetSocketAddress getInetSocketAddress()
Get the InetSocketAddress for the established connection.- Returns:
- the InetSocketAddress for the established connection. (or null, if the connection is no longer established)
-
flush
void flush() throws java.io.IOExceptionFlushes messages that may have been batched by the implementation.- Throws:
java.io.IOException- if the flush fails- See Also:
getBatchMode()
-
-