Class WebSocketRemoteEndpoint
java.lang.Object
org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint
- All Implemented Interfaces:
RemoteEndpoint
Endpoint for Writing messages to the Remote websocket.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate BatchModeprivate static final intprivate final BlockingWriteCallbackprivate final LogicalConnectionprivate static final org.eclipse.jetty.util.log.Loggerprivate intprivate final AtomicIntegerprivate static final WriteCallbackprivate final AtomicIntegerprivate final OutgoingFramesprivate static final intprivate static final intprivate static final int -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoing) WebSocketRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoing, BatchMode batchMode) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidblockingWrite(WebSocketFrame frame) voidflush()Flushes messages that may have been batched by the implementation.private static WriteCallbackfrom(WriteCallback callback, Runnable completed) Get the InetSocketAddress for the established connection.intGet the maximum number of data frames allowed to be waiting to be sent at any one time.private booleansendAsyncFrame(WebSocketFrame frame) InternalvoidsendBytes(ByteBuffer data) Blocking write of bytes.voidsendBytes(ByteBuffer data, WriteCallback callback) Initiates the asynchronous transmission of a binary message.sendBytesByFuture(ByteBuffer data) Initiates the asynchronous transmission of a binary message.voidsendPartialBytes(ByteBuffer fragment, boolean isLast) Send a binary message in pieces, blocking until all of the message has been transmitted.voidsendPartialString(String fragment, boolean isLast) Send a text message in pieces, blocking until all of the message has been transmitted.voidsendPing(ByteBuffer applicationData) Send a Ping message containing the given application data to the remote endpoint.voidsendPong(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(String text) Send a text message, blocking until all bytes of the message has been transmitted.voidsendString(String text, WriteCallback callback) Initiates the asynchronous transmission of a text message.sendStringByFuture(String text) Initiates the asynchronous transmission of a text message.voidsetBatchMode(BatchMode batchMode) 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.toString()voiduncheckedSendFrame(WebSocketFrame frame, WriteCallback callback) private void
-
Field Details
-
NOOP_CALLBACK
-
LOG
private static final org.eclipse.jetty.util.log.Logger LOG -
ASYNC_MASK
private static final int ASYNC_MASK- See Also:
-
BLOCK_MASK
private static final int BLOCK_MASK- See Also:
-
STREAM_MASK
private static final int STREAM_MASK- See Also:
-
PARTIAL_TEXT_MASK
private static final int PARTIAL_TEXT_MASK- See Also:
-
PARTIAL_BINARY_MASK
private static final int PARTIAL_BINARY_MASK- See Also:
-
connection
-
outgoing
-
msgState
-
blocker
-
numOutgoingFrames
-
batchMode
-
maxNumOutgoingFrames
private int maxNumOutgoingFrames
-
-
Constructor Details
-
WebSocketRemoteEndpoint
-
WebSocketRemoteEndpoint
public WebSocketRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoing, BatchMode batchMode)
-
-
Method Details
-
blockingWrite
- Throws:
IOException
-
lockMsg
-
unlockMsg
-
getInetSocketAddress
Get the InetSocketAddress for the established connection.- Specified by:
getInetSocketAddressin interfaceRemoteEndpoint- Returns:
- the InetSocketAddress for the established connection. (or null, if the connection is no longer established)
-
sendAsyncFrame
Internal- Parameters:
frame- the frame to write- Returns:
- the future for the network write of the frame
-
sendBytes
Blocking write of bytes.- Specified by:
sendBytesin interfaceRemoteEndpoint- Parameters:
data- the message to be sent- Throws:
IOException- if unable to send the bytes
-
sendBytesByFuture
Description copied from interface:RemoteEndpointInitiates 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.- Specified by:
sendBytesByFuturein interfaceRemoteEndpoint- Parameters:
data- the data being sent- Returns:
- the Future object representing the send operation.
-
sendBytes
Description copied from interface:RemoteEndpointInitiates 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.- Specified by:
sendBytesin interfaceRemoteEndpoint- Parameters:
data- the data being sentcallback- callback to notify of success or failure of the write operation
-
uncheckedSendFrame
-
sendPartialBytes
Description copied from interface:RemoteEndpointSend 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.- Specified by:
sendPartialBytesin interfaceRemoteEndpoint- Parameters:
fragment- the piece of the message being sentisLast- true if this is the last piece of the partial bytes- Throws:
IOException- if unable to send the partial bytes
-
sendPartialString
Description copied from interface:RemoteEndpointSend 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.- Specified by:
sendPartialStringin interfaceRemoteEndpoint- Parameters:
fragment- the piece of the message being sentisLast- true if this is the last piece of the partial bytes- Throws:
IOException- if unable to send the partial bytes
-
sendPing
Description copied from interface:RemoteEndpointSend 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.- Specified by:
sendPingin interfaceRemoteEndpoint- Parameters:
applicationData- the data to be carried in the ping request- Throws:
IOException- if unable to send the ping
-
sendPong
Description copied from interface:RemoteEndpointAllows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session.- Specified by:
sendPongin interfaceRemoteEndpoint- Parameters:
applicationData- the application data to be carried in the pong response.- Throws:
IOException- if unable to send the pong
-
sendString
Description copied from interface:RemoteEndpointSend a text message, blocking until all bytes of the message has been transmitted.Note: this is a blocking call
- Specified by:
sendStringin interfaceRemoteEndpoint- Parameters:
text- the message to be sent- Throws:
IOException- if unable to send the text message
-
sendStringByFuture
Description copied from interface:RemoteEndpointInitiates 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.- Specified by:
sendStringByFuturein interfaceRemoteEndpoint- Parameters:
text- the text being sent- Returns:
- the Future object representing the send operation.
-
sendString
Description copied from interface:RemoteEndpointInitiates 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.- Specified by:
sendStringin interfaceRemoteEndpoint- Parameters:
text- the text being sentcallback- callback to notify of success or failure of the write operation
-
getBatchMode
- Specified by:
getBatchModein interfaceRemoteEndpoint- Returns:
- the batch mode with which messages are sent.
- See Also:
-
setBatchMode
Description copied from interface:RemoteEndpointSet the batch mode with which messages are sent.- Specified by:
setBatchModein interfaceRemoteEndpoint- Parameters:
batchMode- the batch mode to use- See Also:
-
getMaxOutgoingFrames
public int getMaxOutgoingFrames()Description copied from interface:RemoteEndpointGet 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.- Specified by:
getMaxOutgoingFramesin interfaceRemoteEndpoint- Returns:
- the max number of frames.
-
setMaxOutgoingFrames
public void setMaxOutgoingFrames(int maxOutgoingFrames) Description copied from interface:RemoteEndpointSet 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.- Specified by:
setMaxOutgoingFramesin interfaceRemoteEndpoint- Parameters:
maxOutgoingFrames- the max number of frames.
-
flush
Description copied from interface:RemoteEndpointFlushes messages that may have been batched by the implementation.- Specified by:
flushin interfaceRemoteEndpoint- Throws:
IOException- if the flush fails- See Also:
-
toString
-
from
-