Package org.medcare.igtl.network
Class ServerThread
java.lang.Object
java.lang.Thread
org.medcare.igtl.network.ServerThread
- All Implemented Interfaces:
Runnable
OpenIGTServer create one ServerThread for each client making a connection.
ServerThread will add messages received from client to the messageQueue to be
treated then MessageQueueManager will use its ServerThread to send answer to
messages.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorDescriptionServerThread
(Socket socket, OpenIGTServer openIGTServer) Default ServerThread constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
getAlive()
** To set server status **void
Interrupt this threadvoid
run()
Reader thread.final void
sendBytes
(byte[] bytes) Sends bytesvoid
sendMessage
(OpenIGTMessage message) void
sendMessage
(Header header, byte[] body) void
setAlive
(boolean alive) void
setStatus
(OpenIGTServer.ServerStatus status) ** To set server statusMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
errorManager
-
-
Constructor Details
-
ServerThread
Default ServerThread constructor.- Parameters:
socket
- to listen to- Throws:
IOException
Exception
-
-
Method Details
-
run
public void run()Reader thread. Reads messages from the socket and add them to the MessageQueueManager -
sendMessage
- Throws:
Exception
-
sendMessage
- Throws:
Exception
-
sendBytes
Sends bytes- Parameters:
bytes
- - byte[] array.- Throws:
IOException
- - Exception in I/O.
-
interrupt
public void interrupt()Interrupt this thread -
setStatus
** To set server status- Parameters:
status
- **
-
getStatus
** To set server status **- Returns:
- the status status
-
getAlive
public boolean getAlive() -
setAlive
public void setAlive(boolean alive)
-