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 Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate WebSocketFrameprivate Objectprivate ReadingThread.CloseTaskprivate Timerprivate List<WebSocketFrame> private booleanprivate final PerMessageCompressionExtensionprivate booleanFields inherited from class WebSocketThread
mWebSocketFields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcallOnBinaryFrame(WebSocketFrame frame) CallonBinaryFramemethod of the listeners.private voidcallOnBinaryMessage(byte[] message) Callmethod of the listeners.invalid reference
onBinaryMessageprivate voidcallOnCloseFrame(WebSocketFrame frame) CallonCloseFramemethod of the listeners.private voidCallonContinuationFramemethod of the listeners.private voidcallOnError(WebSocketException cause) CallonErrormethod of the listeners.private voidcallOnFrame(WebSocketFrame frame) CallonFramemethod of the listeners.private voidcallOnFrameError(WebSocketException cause, WebSocketFrame frame) CallonFrameErrormethod of the listeners.private voidcallOnMessageDecompressionError(WebSocketException cause, byte[] compressed) CallonMessageDecompressionErrormethod of the listeners.private voidcallOnMessageError(WebSocketException cause, List<WebSocketFrame> frames) CallonMessageErrormethod of the listeners.private voidcallOnPingFrame(WebSocketFrame frame) CallonPingFramemethod of the listeners.private voidcallOnPongFrame(WebSocketFrame frame) CallonPongFramemethod of the listeners.private voidcallOnTextFrame(WebSocketFrame frame) CallonTextFramemethod of the listeners.private voidcallOnTextMessage(byte[] data) CallonTextMessagemethod of the listeners.private voidcallOnTextMessage(String message) CallonTextMessagemethod of the listeners.private voidcallOnTextMessageError(WebSocketException cause, byte[] data) CallonTextMessageErrormethod of the listeners.private voidprivate voidprivate byte[]concatenatePayloads(List<WebSocketFrame> frames) private WebSocketFrameprivate byte[]decompress(byte[] input) private byte[]getMessage(WebSocketFrame frame) private byte[]getMessage(List<WebSocketFrame> frames) private booleanhandleBinaryFrame(WebSocketFrame frame) private booleanhandleCloseFrame(WebSocketFrame frame) private booleanprivate booleanhandleFrame(WebSocketFrame frame) private booleanhandlePingFrame(WebSocketFrame frame) private booleanhandlePongFrame(WebSocketFrame frame) private booleanhandleTextFrame(WebSocketFrame frame) private voidmain()private voidprivate WebSocketFrame(package private) voidrequestStop(long closeDelay) voidrunMain()private voidprivate voidprivate voidverifyFrame(WebSocketFrame frame) private voidprivate voidverifyFrameMask(WebSocketFrame frame) Ensure that the given frame is not masked.private voidverifyFrameOpcode(WebSocketFrame frame) Ensure that the opcode of the give frame is a known one.private voidverifyFrameSize(WebSocketFrame frame) private voidverifyReservedBit1(WebSocketFrame frame) Verify the RSV1 bit of a frame.private booleanVerify the RSV1 bit of a frame using the rule described in RFC 7692.private voidverifyReservedBit2(WebSocketFrame frame) Verify the RSV2 bit of a frame.private voidverifyReservedBit3(WebSocketFrame frame) Verify the RSV3 bit of a frame.private voidverifyReservedBits(WebSocketFrame frame) private voidMethods inherited from class WebSocketThread
callOnThreadCreated, runMethods inherited from class 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:
runMainin classWebSocketThread
-
main
private void main() -
requestStop
void requestStop(long closeDelay) -
callOnFrame
CallonFramemethod of the listeners. -
callOnContinuationFrame
CallonContinuationFramemethod of the listeners. -
callOnTextFrame
CallonTextFramemethod of the listeners. -
callOnBinaryFrame
CallonBinaryFramemethod of the listeners. -
callOnCloseFrame
CallonCloseFramemethod of the listeners. -
callOnPingFrame
CallonPingFramemethod of the listeners. -
callOnPongFrame
CallonPongFramemethod of the listeners. -
callOnTextMessage
private void callOnTextMessage(byte[] data) CallonTextMessagemethod of the listeners. -
callOnTextMessage
CallonTextMessagemethod of the listeners. -
callOnBinaryMessage
private void callOnBinaryMessage(byte[] message) Callmethod of the listeners.invalid reference
onBinaryMessage -
callOnError
CallonErrormethod of the listeners. -
callOnFrameError
CallonFrameErrormethod of the listeners. -
callOnMessageError
CallonMessageErrormethod of the listeners. -
callOnMessageDecompressionError
CallonMessageDecompressionErrormethod of the listeners. -
callOnTextMessageError
CallonTextMessageErrormethod 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()
-