|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.mischiefbox.dmud.net.ConnectionInfo
Connection information object. Provides information about a single connection. Handles the input for the connection in an asynchronous thread--passes the input to the connection handler which will delegate processing to the input queue object. Ouput is handled via an immediate method call from the connection handler.
| Field Summary | |
protected BufferedInputStream |
bis
The input stream associated with the socket. |
protected BufferedOutputStream |
bos
The output stream associated with the socket. |
protected boolean |
bProcessing
Indicates this is is processing input. |
protected ConnectionHandler |
handler
The connection handler that created and is responsible for the connection. |
protected int |
iErrorCount
The consecutive error count on the connection. |
protected long |
lLastUseMillis
The last recorded time I/O was performed on the socket. |
static int |
MAX_ERROR
The maximum number of consecutive errors permitted for the connection. |
protected String |
sConnectionId
The connection id (used to identify the connection). |
protected static int |
SLEEP_MILLIS
The sleep time for this thread (in between checks for new input). |
protected Socket |
sock
The Socket associated with the connection. |
protected Thread |
tProcessor
The thread that processes input. |
| Constructor Summary | |
ConnectionInfo(ConnectionHandler handler,
Socket sock,
int iConnectionId)
Create a new connection info object. |
|
| Method Summary | |
void |
addError()
Add to and check the error count. |
protected void |
finalize()
Finalizer, in case this goes out of scope. |
String |
getConnectionId()
Get the connection id. |
int |
getErrors()
Get the number of errors on the connection. |
BufferedInputStream |
getInputStream()
Get the input stream. |
long |
getLastUsedTime()
Get the last used time (in milliseconds). |
BufferedOutputStream |
getOutputStream()
Get the output stream. |
boolean |
isProcessing()
Indicates if this is processing input. |
void |
resetError()
Reset the error count to zero (success in I/O). |
void |
run()
Process input on the socket. |
void |
setLastUsedTime()
Set the last used time to now. |
void |
shutdown()
Shut down the connection gracefully. |
void |
terminate()
Close the socket connection immediately. |
boolean |
writeMessage(byte[] baMessage)
Accept a message to be written to the client socket. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final int SLEEP_MILLIS
public static final int MAX_ERROR
protected ConnectionHandler handler
protected Socket sock
protected BufferedInputStream bis
protected BufferedOutputStream bos
protected String sConnectionId
protected int iErrorCount
protected long lLastUseMillis
protected boolean bProcessing
protected Thread tProcessor
| Constructor Detail |
public ConnectionInfo(ConnectionHandler handler,
Socket sock,
int iConnectionId)
handler - the connection handler that created the
connection info object.sock - the socket this connection will use for I/O.iConnectionId - the connection id.| Method Detail |
public void run()
run in interface Runnablepublic boolean writeMessage(byte[] baMessage)
baMessage - the message to be written.public boolean isProcessing()
public String getConnectionId()
public long getLastUsedTime()
public void setLastUsedTime()
public BufferedInputStream getInputStream()
public BufferedOutputStream getOutputStream()
public void terminate()
public void shutdown()
public int getErrors()
public void addError()
public void resetError()
protected void finalize()
throws Throwable
finalize in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||