public abstract class AbstractConnection extends Thread implements Closeable
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractConnection.LineReaderInputStream |
protected static class |
AbstractConnection.State |
Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
protected Socket |
client |
protected AbstractConnection.LineReaderInputStream |
in |
protected OutputStream |
os |
protected String |
password |
protected ExchangeSession |
session |
protected AbstractConnection.State |
state |
protected String |
userName |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
AbstractConnection(String name,
Socket clientSocket)
Only set the thread name and socket
|
AbstractConnection(String name,
Socket clientSocket,
String encoding)
Initialize the streams and set thread name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close client connection, streams and Exchange session .
|
void |
logConnection(String action,
String userName) |
String |
readClient()
Read a line from the client connection.
|
void |
sendClient(byte[] messageBytes)
Send only bytes to client.
|
void |
sendClient(byte[] messageBytes,
int offset,
int length)
Send only bytes to client.
|
void |
sendClient(String message)
Send message to client followed by CRLF.
|
void |
sendClient(String prefix,
String message)
Send prefix and message to client followed by CRLF.
|
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, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprotected final Socket client
protected AbstractConnection.LineReaderInputStream in
protected OutputStream os
protected String userName
protected String password
protected AbstractConnection.State state
protected ExchangeSession session
public AbstractConnection(String name, Socket clientSocket)
name - thread type nameclientSocket - client socketpublic void sendClient(String message) throws IOException
message - messageIOException - on errorpublic void sendClient(String prefix, String message) throws IOException
prefix - prefixmessage - messageIOException - on errorpublic void sendClient(byte[] messageBytes)
throws IOException
messageBytes - contentIOException - on errorpublic void sendClient(byte[] messageBytes,
int offset,
int length)
throws IOException
messageBytes - contentoffset - the start offset in the data.length - the number of bytes to write.IOException - on errorpublic String readClient() throws IOException
IOException - when unable to read linepublic void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2001–2025 MickaĆ«l Guessant. All rights reserved.