Package com.neovisionaries.ws.client
Class WritingThread
- java.lang.Object
-
- java.lang.Thread
-
- com.neovisionaries.ws.client.WebSocketThread
-
- com.neovisionaries.ws.client.WritingThread
-
- All Implemented Interfaces:
java.lang.Runnable
class WritingThread extends WebSocketThread
-
-
Field Summary
Fields Modifier and Type Field Description private static int
FLUSH_THRESHOLD
private WebSocketFrame
mCloseFrame
private boolean
mFlushNeeded
private java.util.LinkedList<WebSocketFrame>
mFrames
private PerMessageCompressionExtension
mPMCE
private boolean
mStopped
private boolean
mStopRequested
private static int
SHOULD_CONTINUE
private static int
SHOULD_FLUSH
private static int
SHOULD_SEND
private static int
SHOULD_STOP
-
Fields inherited from class com.neovisionaries.ws.client.WebSocketThread
mWebSocket
-
-
Constructor Summary
Constructors Constructor Description WritingThread(WebSocket websocket)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addHighPriorityFrame(WebSocketFrame frame)
private void
changeToClosing()
private void
doFlush()
private void
flush()
private long
flushIfLongInterval(long lastFlushAt)
private void
flushIgnoreError()
private boolean
isFlushNeeded(boolean last)
private static boolean
isHighPriorityFrame(WebSocketFrame frame)
private void
main()
private void
notifyFinished()
void
queueFlush()
boolean
queueFrame(WebSocketFrame frame)
void
requestStop()
void
runMain()
private void
sendFrame(WebSocketFrame frame)
private void
sendFrames(boolean last)
private int
waitForFrames()
-
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 Detail
-
SHOULD_SEND
private static final int SHOULD_SEND
- See Also:
- Constant Field Values
-
SHOULD_STOP
private static final int SHOULD_STOP
- See Also:
- Constant Field Values
-
SHOULD_CONTINUE
private static final int SHOULD_CONTINUE
- See Also:
- Constant Field Values
-
SHOULD_FLUSH
private static final int SHOULD_FLUSH
- See Also:
- Constant Field Values
-
FLUSH_THRESHOLD
private static final int FLUSH_THRESHOLD
- See Also:
- Constant Field Values
-
mFrames
private final java.util.LinkedList<WebSocketFrame> mFrames
-
mPMCE
private final PerMessageCompressionExtension mPMCE
-
mStopRequested
private boolean mStopRequested
-
mCloseFrame
private WebSocketFrame mCloseFrame
-
mFlushNeeded
private boolean mFlushNeeded
-
mStopped
private boolean mStopped
-
-
Constructor Detail
-
WritingThread
public WritingThread(WebSocket websocket)
-
-
Method Detail
-
runMain
public void runMain()
- Specified by:
runMain
in classWebSocketThread
-
main
private void main()
-
requestStop
public void requestStop()
-
queueFrame
public boolean queueFrame(WebSocketFrame frame)
-
isHighPriorityFrame
private static boolean isHighPriorityFrame(WebSocketFrame frame)
-
addHighPriorityFrame
private void addHighPriorityFrame(WebSocketFrame frame)
-
queueFlush
public void queueFlush()
-
flushIgnoreError
private void flushIgnoreError()
-
flush
private void flush() throws java.io.IOException
- Throws:
java.io.IOException
-
waitForFrames
private int waitForFrames()
-
sendFrames
private void sendFrames(boolean last) throws WebSocketException
- Throws:
WebSocketException
-
isFlushNeeded
private boolean isFlushNeeded(boolean last)
-
flushIfLongInterval
private long flushIfLongInterval(long lastFlushAt) throws WebSocketException
- Throws:
WebSocketException
-
doFlush
private void doFlush() throws WebSocketException
- Throws:
WebSocketException
-
sendFrame
private void sendFrame(WebSocketFrame frame) throws WebSocketException
- Throws:
WebSocketException
-
changeToClosing
private void changeToClosing()
-
notifyFinished
private void notifyFinished()
-
-