Package com.neovisionaries.ws.client
Class ReadingThread
java.lang.Object
java.lang.Thread
com.neovisionaries.ws.client.WebSocketThread
com.neovisionaries.ws.client.ReadingThread
- All Implemented Interfaces:
Runnable
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
private WebSocketFrame
private Object
private ReadingThread.CloseTask
private Timer
private List
<WebSocketFrame> private boolean
private final PerMessageCompressionExtension
private boolean
Fields inherited from class com.neovisionaries.ws.client.WebSocketThread
mWebSocket
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
callOnBinaryFrame
(WebSocketFrame frame) CallonBinaryFrame
method of the listeners.private void
callOnBinaryMessage
(byte[] message) Callinvalid reference
onBinaryMessage
private void
callOnCloseFrame
(WebSocketFrame frame) CallonCloseFrame
method of the listeners.private void
CallonContinuationFrame
method of the listeners.private void
callOnError
(WebSocketException cause) CallonError
method of the listeners.private void
callOnFrame
(WebSocketFrame frame) CallonFrame
method of the listeners.private void
callOnFrameError
(WebSocketException cause, WebSocketFrame frame) CallonFrameError
method of the listeners.private void
callOnMessageDecompressionError
(WebSocketException cause, byte[] compressed) CallonMessageDecompressionError
method of the listeners.private void
callOnMessageError
(WebSocketException cause, List<WebSocketFrame> frames) CallonMessageError
method of the listeners.private void
callOnPingFrame
(WebSocketFrame frame) CallonPingFrame
method of the listeners.private void
callOnPongFrame
(WebSocketFrame frame) CallonPongFrame
method of the listeners.private void
callOnTextFrame
(WebSocketFrame frame) CallonTextFrame
method of the listeners.private void
callOnTextMessage
(byte[] data) CallonTextMessage
method of the listeners.private void
callOnTextMessage
(String message) CallonTextMessage
method of the listeners.private void
callOnTextMessageError
(WebSocketException cause, byte[] data) CallonTextMessageError
method of the listeners.private void
private void
private byte[]
concatenatePayloads
(List<WebSocketFrame> frames) private WebSocketFrame
private byte[]
decompress
(byte[] input) private byte[]
getMessage
(WebSocketFrame frame) private byte[]
getMessage
(List<WebSocketFrame> frames) private boolean
handleBinaryFrame
(WebSocketFrame frame) private boolean
handleCloseFrame
(WebSocketFrame frame) private boolean
private boolean
handleFrame
(WebSocketFrame frame) private boolean
handlePingFrame
(WebSocketFrame frame) private boolean
handlePongFrame
(WebSocketFrame frame) private boolean
handleTextFrame
(WebSocketFrame frame) private void
main()
private void
private WebSocketFrame
(package private) void
requestStop
(long closeDelay) void
runMain()
private void
private void
private void
verifyFrame
(WebSocketFrame frame) private void
private void
verifyFrameMask
(WebSocketFrame frame) Ensure that the given frame is not masked.private void
verifyFrameOpcode
(WebSocketFrame frame) Ensure that the opcode of the give frame is a known one.private void
verifyFrameSize
(WebSocketFrame frame) private void
verifyReservedBit1
(WebSocketFrame frame) Verify the RSV1 bit of a frame.private boolean
Verify the RSV1 bit of a frame using the rule described in RFC 7692.private void
verifyReservedBit2
(WebSocketFrame frame) Verify the RSV2 bit of a frame.private void
verifyReservedBit3
(WebSocketFrame frame) Verify the RSV3 bit of a frame.private void
verifyReservedBits
(WebSocketFrame frame) private void
Methods inherited from class com.neovisionaries.ws.client.WebSocketThread
callOnThreadCreated, run
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
-
Field Details
-
mStopRequested
private boolean mStopRequested -
mCloseFrame
-
mContinuation
-
mPMCE
-
mCloseLock
-
mCloseTimer
-
mCloseTask
-
mCloseDelay
private long mCloseDelay -
mNotWaitForCloseFrame
private boolean mNotWaitForCloseFrame
-
-
Constructor Details
-
ReadingThread
-
-
Method Details
-
runMain
public void runMain()- Specified by:
runMain
in classWebSocketThread
-
main
private void main() -
requestStop
void requestStop(long closeDelay) -
callOnFrame
CallonFrame
method of the listeners. -
callOnContinuationFrame
CallonContinuationFrame
method of the listeners. -
callOnTextFrame
CallonTextFrame
method of the listeners. -
callOnBinaryFrame
CallonBinaryFrame
method of the listeners. -
callOnCloseFrame
CallonCloseFrame
method of the listeners. -
callOnPingFrame
CallonPingFrame
method of the listeners. -
callOnPongFrame
CallonPongFrame
method of the listeners. -
callOnTextMessage
private void callOnTextMessage(byte[] data) CallonTextMessage
method of the listeners. -
callOnTextMessage
CallonTextMessage
method of the listeners. -
callOnBinaryMessage
private void callOnBinaryMessage(byte[] message) Callinvalid reference
onBinaryMessage
-
callOnError
CallonError
method of the listeners. -
callOnFrameError
CallonFrameError
method of the listeners. -
callOnMessageError
CallonMessageError
method of the listeners. -
callOnMessageDecompressionError
CallonMessageDecompressionError
method of the listeners. -
callOnTextMessageError
CallonTextMessageError
method of the listeners. -
readFrame
-
verifyFrame
- Throws:
WebSocketException
-
verifyReservedBits
- Throws:
WebSocketException
-
verifyReservedBit1
Verify the RSV1 bit of a frame.- Throws:
WebSocketException
-
verifyReservedBit1ForPMCE
Verify the RSV1 bit of a frame using the rule described in RFC 7692. See 6. Framing in RFC 7692 for details.- Throws:
WebSocketException
-
verifyReservedBit2
Verify the RSV2 bit of a frame.- Throws:
WebSocketException
-
verifyReservedBit3
Verify the RSV3 bit of a frame.- Throws:
WebSocketException
-
verifyFrameOpcode
Ensure that the opcode of the give frame is a known one.From RFC 6455, 5.2. Base Framing Protocol
If an unknown opcode is received, the receiving endpoint MUST Fail the WebSocket Connection.
- Throws:
WebSocketException
-
verifyFrameMask
Ensure that the given frame is not masked.From RFC 6455, 5.1. Overview:
A server MUST NOT mask any frames that it sends to the client. A client MUST close a connection if it detects a masked frame.
- Throws:
WebSocketException
-
verifyFrameFragmentation
- Throws:
WebSocketException
-
verifyFrameSize
- Throws:
WebSocketException
-
createCloseFrame
-
handleFrame
-
handleContinuationFrame
-
getMessage
-
concatenatePayloads
-
getMessage
-
decompress
private byte[] decompress(byte[] input) -
handleTextFrame
-
handleBinaryFrame
-
handleCloseFrame
-
handlePingFrame
-
handlePongFrame
-
waitForCloseFrame
private void waitForCloseFrame() -
notifyFinished
private void notifyFinished() -
scheduleClose
private void scheduleClose() -
scheduleCloseTask
private void scheduleCloseTask() -
cancelClose
private void cancelClose() -
cancelCloseTask
private void cancelCloseTask()
-