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 Summary
Nested classes/interfaces inherited from interface jakarta.websocket.RemoteEndpoint
RemoteEndpoint.Async, RemoteEndpoint.Basic
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Semaphore
protected static final SendResult
protected static final StringManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
acquireMessagePartInProgressSemaphore
(byte opCode, long timeoutExpiry) Acquire the semaphore that allows a message part to be written.final void
close()
protected abstract void
doClose()
protected abstract void
doWrite
(SendHandler handler, long blockingWriteTimeoutExpiry, ByteBuffer... data) void
Flush any currently batched messages to the remote endpoint.boolean
Obtains the current batching status of the endpoint.protected abstract Lock
getLock()
long
protected abstract boolean
isMasked()
void
sendBytes
(ByteBuffer data) void
sendBytesByCompletion
(ByteBuffer data, SendHandler handler) sendBytesByFuture
(ByteBuffer data) void
sendObject
(Object obj) void
sendObjectByCompletion
(Object obj, SendHandler completion) sendObjectByFuture
(Object obj) void
sendPartialBytes
(ByteBuffer partialByte, boolean last) void
sendPartialString
(String fragment, boolean isLast) void
sendPing
(ByteBuffer applicationData) Send a ping message blocking until the message has been sent.void
sendPong
(ByteBuffer applicationData) Send a pong message blocking until the message has been sent.void
sendString
(String text) void
sendStringByCompletion
(String text, SendHandler handler) sendStringByFuture
(String text) void
setBatchingAllowed
(boolean batchingAllowed) Enable or disable the batching of outgoing messages for this endpoint.protected void
setEncoders
(EndpointConfig endpointConfig) void
setSendTimeout
(long timeout) protected void
setSession
(WsSession wsSession) protected void
setTransformation
(Transformation transformation) protected void
updateStats
(long payloadLength) Hook for updating server side statistics.
-
Field Details
-
sm
-
SENDRESULT_OK
-
messagePartInProgress
-
-
Constructor Details
-
WsRemoteEndpointImplBase
public WsRemoteEndpointImplBase()
-
-
Method Details
-
setTransformation
-
getSendTimeout
public long getSendTimeout() -
setSendTimeout
public void setSendTimeout(long timeout) -
setBatchingAllowed
Description copied from interface:jakarta.websocket.RemoteEndpoint
Enable 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:
setBatchingAllowed
in interfaceRemoteEndpoint
- Parameters:
batchingAllowed
- New setting- Throws:
IOException
- If changing the value resulted in a call toRemoteEndpoint.flushBatch()
and that call threw anIOException
.
-
getBatchingAllowed
public boolean getBatchingAllowed()Description copied from interface:jakarta.websocket.RemoteEndpoint
Obtains the current batching status of the endpoint.- Specified by:
getBatchingAllowed
in interfaceRemoteEndpoint
- Returns:
true
if batching is enabled, otherwisefalse
.
-
flushBatch
Description copied from interface:jakarta.websocket.RemoteEndpoint
Flush any currently batched messages to the remote endpoint. This method will block until the flush completes.- Specified by:
flushBatch
in interfaceRemoteEndpoint
- Throws:
IOException
- If an I/O error occurs while flushing
-
sendBytes
- Throws:
IOException
-
sendBytesByFuture
-
sendBytesByCompletion
-
sendPartialBytes
- Throws:
IOException
-
sendPing
Description copied from interface:jakarta.websocket.RemoteEndpoint
Send 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:
sendPing
in interfaceRemoteEndpoint
- Parameters:
applicationData
- The payload for the ping message- Throws:
IOException
- If an I/O error occurs while sending the pingIllegalArgumentException
- if the applicationData is too large for a control message (max 125 bytes)
-
sendPong
Description copied from interface:jakarta.websocket.RemoteEndpoint
Send 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:
sendPong
in interfaceRemoteEndpoint
- Parameters:
applicationData
- The payload for the pong message- Throws:
IOException
- If an I/O error occurs while sending the pongIllegalArgumentException
- if the applicationData is too large for a control message (max 125 bytes)
-
sendString
- Throws:
IOException
-
sendStringByFuture
-
sendStringByCompletion
-
sendPartialString
- Throws:
IOException
-
getSendStream
-
getSendWriter
-
acquireMessagePartInProgressSemaphore
protected 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 writtentimeoutExpiry
- The time when the attempt to acquire the semaphore should expire- Returns:
true
if the semaphore is obtained, otherwisefalse
.- Throws:
InterruptedException
- If the wait for the semaphore is interrupted
-
updateStats
protected 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
-
close
public final void close() -
doWrite
protected abstract void doWrite(SendHandler handler, long blockingWriteTimeoutExpiry, ByteBuffer... data) -
isMasked
protected abstract boolean isMasked() -
doClose
protected abstract void doClose() -
getLock
-