Package org.apache.tomcat.websocket
Class WsRemoteEndpointImplBase
java.lang.Object
org.apache.tomcat.websocket.WsRemoteEndpointImplBase
- All Implemented Interfaces:
- RemoteEndpoint
- Direct Known Subclasses:
- WsRemoteEndpointImplClient,- WsRemoteEndpointImplServer
- 
Nested Class SummaryNested classes/interfaces inherited from interface jakarta.websocket.RemoteEndpointRemoteEndpoint.Async, RemoteEndpoint.Basic
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final Semaphoreprotected static final SendResultprotected static final StringManager
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleanacquireMessagePartInProgressSemaphore(byte opCode, long timeoutExpiry) Acquire the semaphore that allows a message part to be written.final voidclose()protected abstract voiddoClose()protected abstract voiddoWrite(SendHandler handler, long blockingWriteTimeoutExpiry, ByteBuffer... data) voidFlush any currently batched messages to the remote endpoint.booleanObtains the current batching status of the endpoint.protected abstract LockgetLock()longprotected abstract booleanisMasked()voidsendBytes(ByteBuffer data) voidsendBytesByCompletion(ByteBuffer data, SendHandler handler) sendBytesByFuture(ByteBuffer data) voidsendObject(Object obj) voidsendObjectByCompletion(Object obj, SendHandler completion) sendObjectByFuture(Object obj) voidsendPartialBytes(ByteBuffer partialByte, boolean last) voidsendPartialString(String fragment, boolean isLast) voidsendPing(ByteBuffer applicationData) Send a ping message blocking until the message has been sent.voidsendPong(ByteBuffer applicationData) Send a pong message blocking until the message has been sent.voidsendString(String text) voidsendStringByCompletion(String text, SendHandler handler) sendStringByFuture(String text) voidsetBatchingAllowed(boolean batchingAllowed) Enable or disable the batching of outgoing messages for this endpoint.protected voidsetEncoders(EndpointConfig endpointConfig) voidsetSendTimeout(long timeout) protected voidsetSession(WsSession wsSession) protected voidsetTransformation(Transformation transformation) protected voidupdateStats(long payloadLength) Hook for updating server side statistics.
- 
Field Details- 
sm
- 
SENDRESULT_OK
- 
messagePartInProgress
 
- 
- 
Constructor Details- 
WsRemoteEndpointImplBasepublic WsRemoteEndpointImplBase()
 
- 
- 
Method Details- 
setTransformation
- 
getSendTimeoutpublic long getSendTimeout()
- 
setSendTimeoutpublic void setSendTimeout(long timeout) 
- 
setBatchingAllowedDescription copied from interface:jakarta.websocket.RemoteEndpointEnable or disable the batching of outgoing messages for this endpoint. If batching is disabled when it was previously enabled then this method will block until any currently batched messages have been written.- Specified by:
- setBatchingAllowedin interface- RemoteEndpoint
- Parameters:
- batchingAllowed- New setting
- Throws:
- IOException- If changing the value resulted in a call to- RemoteEndpoint.flushBatch()and that call threw an- IOException.
 
- 
getBatchingAllowedpublic boolean getBatchingAllowed()Description copied from interface:jakarta.websocket.RemoteEndpointObtains the current batching status of the endpoint.- Specified by:
- getBatchingAllowedin interface- RemoteEndpoint
- Returns:
- trueif batching is enabled, otherwise- false.
 
- 
flushBatchDescription copied from interface:jakarta.websocket.RemoteEndpointFlush any currently batched messages to the remote endpoint. This method will block until the flush completes.- Specified by:
- flushBatchin interface- RemoteEndpoint
- Throws:
- IOException- If an I/O error occurs while flushing
 
- 
sendBytes- Throws:
- IOException
 
- 
sendBytesByFuture
- 
sendBytesByCompletion
- 
sendPartialBytes- Throws:
- IOException
 
- 
sendPingDescription copied from interface:jakarta.websocket.RemoteEndpointSend a ping message blocking until the message has been sent. Note that if a message is in the process of being sent asynchronously, this method will block until that message and this ping has been sent.- Specified by:
- sendPingin interface- RemoteEndpoint
- Parameters:
- applicationData- The payload for the ping message
- Throws:
- IOException- If an I/O error occurs while sending the ping
- IllegalArgumentException- if the applicationData is too large for a control message (max 125 bytes)
 
- 
sendPongDescription copied from interface:jakarta.websocket.RemoteEndpointSend a pong message blocking until the message has been sent. Note that if a message is in the process of being sent asynchronously, this method will block until that message and this pong has been sent.- Specified by:
- sendPongin interface- RemoteEndpoint
- Parameters:
- applicationData- The payload for the pong message
- Throws:
- IOException- If an I/O error occurs while sending the pong
- IllegalArgumentException- if the applicationData is too large for a control message (max 125 bytes)
 
- 
sendString- Throws:
- IOException
 
- 
sendStringByFuture
- 
sendStringByCompletion
- 
sendPartialString- Throws:
- IOException
 
- 
getSendStream
- 
getSendWriter
- 
acquireMessagePartInProgressSemaphoreprotected boolean acquireMessagePartInProgressSemaphore(byte opCode, long timeoutExpiry) throws InterruptedException Acquire the semaphore that allows a message part to be written.- Parameters:
- opCode- The OPCODE for the message to be written
- timeoutExpiry- The time when the attempt to acquire the semaphore should expire
- Returns:
- trueif the semaphore is obtained, otherwise- false.
- Throws:
- InterruptedException- If the wait for the semaphore is interrupted
 
- 
updateStatsprotected void updateStats(long payloadLength) Hook for updating server side statistics. Called on every frame written (including when batching is enabled and the frames are buffered locally until the buffer is full or is flushed).- Parameters:
- payloadLength- Size of message payload
 
- 
sendObject- Throws:
- IOException
- EncodeException
 
- 
sendObjectByFuture
- 
sendObjectByCompletion
- 
setSession
- 
setEncoders- Throws:
- DeploymentException
 
- 
closepublic final void close()
- 
doWriteprotected abstract void doWrite(SendHandler handler, long blockingWriteTimeoutExpiry, ByteBuffer... data) 
- 
isMaskedprotected abstract boolean isMasked()
- 
doCloseprotected abstract void doClose()
- 
getLock
 
-