Package org.medcare.igtl.network
Class OpenIGTClient
java.lang.Object
java.lang.Thread
org.medcare.igtl.network.OpenIGTClient
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
GenericIGTLinkClient
The class can be used by first connecting to a server sending requests comming from the requestQueue, listening for response and adding response to the responsqueue
-
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
ConstructorDescriptionOpenIGTClient
(String host, int port, ErrorManager errorManager) Default OpenIGTClient constructor. -
Method Summary
Modifier and TypeMethodDescriptionabstract ResponseHandler
getResponseHandler
(Header header, byte[] bodyBuf) ** To get response Handler** To set server status **void
Interrupt this threadboolean
void
run()
Reader thread.final boolean
sendBytes
(byte[] bytes) Sends bytesvoid
sendMessage
(OpenIGTMessage message) void
sendMessage
(Header header, byte[] body) void
setSocketFactory
(SocketFactory socketFactory) void
** 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
-
OpenIGTClient
public OpenIGTClient(String host, int port, ErrorManager errorManager) throws UnknownHostException, IOException Default OpenIGTClient constructor.- Parameters:
host
- to be connectedport
- of the hosterrorManager
- main class running this client- Throws:
IOException
UnknownHostException
-
-
Method Details
-
run
public void run()Reader thread. Reads messages from the socket and add them to the ResponseQueueManager -
setSocketFactory
-
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 -
getStatus
** To set server status **- Returns:
- the status status
-
setStatus
** To set server status- Parameters:
status
- **
-
getResponseHandler
** To get response Handler- Parameters:
header
- header of the message receivedbodyBuf
- byte array of the body of the message received **- Returns:
- the response Handler
-
isConnected
public boolean isConnected()
-