public class PushMessagesWorker
extends java.lang.Thread
IMPORTANT: Do not use logging anywhere inside this class. When an authentication plugin is running during session establishment with the P2J server using logging no messages are written into the log and the application becomes deadlocked.
Modifier and Type | Field and Description |
---|---|
private java.util.Deque<java.lang.Object> |
messages
Keyboard input queue.
|
private org.eclipse.jetty.websocket.api.RemoteEndpoint |
remote
Remote endpoint.
|
private boolean |
running
Running flag.
|
private org.eclipse.jetty.websocket.api.Session |
session
Remote session.
|
private static long |
WAIT_TO_DIE
Time in milliseconds to wait for the thread exit.
|
Constructor and Description |
---|
PushMessagesWorker(org.eclipse.jetty.websocket.api.Session session)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
pushMessage(java.lang.Object message)
Add a new message at the end of the FIFO queue and notify the push thread.
|
void |
run()
Get messages from queue and send.
|
private void |
sendMessage()
Send a message.
|
void |
stopPushing()
Kill thread and wait to die.
|
private void |
waitForMessages()
Block if the queue is empty.
|
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
private static final long WAIT_TO_DIE
private volatile java.util.Deque<java.lang.Object> messages
private volatile org.eclipse.jetty.websocket.api.Session session
private volatile org.eclipse.jetty.websocket.api.RemoteEndpoint remote
private volatile boolean running
public PushMessagesWorker(org.eclipse.jetty.websocket.api.Session session)
session
- Remote end point connection.public void pushMessage(java.lang.Object message)
message
- A binary or a text message.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void stopPushing()
private void waitForMessages()
running
flag.private void sendMessage()