Package org.apache.tomcat.websocket
Class WsFrameBase
- java.lang.Object
-
- org.apache.tomcat.websocket.WsFrameBase
-
- Direct Known Subclasses:
WsFrameClient
,WsFrameServer
public abstract class WsFrameBase extends java.lang.Object
Takes the ServletInputStream, processes the WebSocket frames it contains and extracts the messages. WebSocket Pings received will be responded to automatically without any action required by the application.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
WsFrameBase.ReadState
WAITING - not suspended Server case: waiting for a notification that data is ready to be read from the socket, the socket is registered to the poller Client case: data has been read from the socket and is waiting for data to be processed PROCESSING - not suspended Server case: reading from the socket and processing the data Client case: processing the data if such has already been read and more data will be read from the socket SUSPENDING_WAIT - suspended, a call to suspend() was made while in WAITING state.
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.ByteBuffer
inputBuffer
protected WsSession
wsSession
-
Constructor Summary
Constructors Constructor Description WsFrameBase(WsSession wsSession, Transformation transformation)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static long
byteArrayToLong(byte[] b, int start, int len)
protected void
changeReadState(WsFrameBase.ReadState newState)
protected boolean
changeReadState(WsFrameBase.ReadState oldState, WsFrameBase.ReadState newState)
protected abstract Log
getLog()
protected WsFrameBase.ReadState
getReadState()
protected Transformation
getTransformation()
protected abstract boolean
isMasked()
protected boolean
isOpen()
protected boolean
isSuspended()
protected void
processInputBuffer()
void
resume()
protected abstract void
resumeProcessing()
This method will be invoked when the read operation is resumed.protected void
sendMessageBinary(java.nio.ByteBuffer msg, boolean last)
protected void
sendMessageText(boolean last)
void
suspend()
protected void
updateStats(long payloadLength)
Hook for updating server side statistics.
-
-
-
Field Detail
-
wsSession
protected final WsSession wsSession
-
inputBuffer
protected final java.nio.ByteBuffer inputBuffer
-
-
Constructor Detail
-
WsFrameBase
public WsFrameBase(WsSession wsSession, Transformation transformation)
-
-
Method Detail
-
processInputBuffer
protected void processInputBuffer() throws java.io.IOException
- Throws:
java.io.IOException
-
isMasked
protected abstract boolean isMasked()
-
getLog
protected abstract Log getLog()
-
updateStats
protected void updateStats(long payloadLength)
Hook for updating server side statistics. Called on every frame received.- Parameters:
payloadLength
- Size of message payload
-
sendMessageText
protected void sendMessageText(boolean last) throws WsIOException
- Throws:
WsIOException
-
sendMessageBinary
protected void sendMessageBinary(java.nio.ByteBuffer msg, boolean last) throws WsIOException
- Throws:
WsIOException
-
byteArrayToLong
protected static long byteArrayToLong(byte[] b, int start, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
isOpen
protected boolean isOpen()
-
getTransformation
protected Transformation getTransformation()
-
suspend
public void suspend()
-
resume
public void resume()
-
isSuspended
protected boolean isSuspended()
-
getReadState
protected WsFrameBase.ReadState getReadState()
-
changeReadState
protected void changeReadState(WsFrameBase.ReadState newState)
-
changeReadState
protected boolean changeReadState(WsFrameBase.ReadState oldState, WsFrameBase.ReadState newState)
-
resumeProcessing
protected abstract void resumeProcessing()
This method will be invoked when the read operation is resumed. As the suspend of the read operation can be invoked at any time, when implementing this method one should consider that there might still be data remaining into the internal buffers that needs to be processed before reading again from the socket.
-
-