|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--net.directj.csf.impl.ClientHandlerImpl
This class is in charge of a client connection. It allow the user to do answer. This implementation is VERY simple, and must not be used as is.
| Field Summary | |
private java.lang.String |
hostname
The client's hostname. |
private java.io.BufferedReader |
in
The input reader. |
private java.lang.String |
ip
The client's IP. |
private java.io.PrintWriter |
out
The output writer. |
private java.lang.Thread |
runner
The handler thread. |
private boolean |
running
Indicates if the handler is running or not. |
private Server |
server
The server that stored the handler. |
private java.net.Socket |
sock
The socket. |
| Constructor Summary | |
ClientHandlerImpl(java.net.Socket _sock,
Server _server)
Creates a ClientHandler implementation. |
|
ClientHandlerImpl(java.net.Socket _sock,
Server _server,
int _timeout)
Creates a ClientHandler implementation |
|
| Method Summary | |
void |
doRequest(byte[] _data)
Send an request to the client. |
java.lang.String |
getClientHostAddress()
Returns the client's IP. |
java.lang.String |
getClientHostName()
Returns the client's hostname. |
boolean |
isRunning()
Indicates if the handler is running or not. |
void |
onRequest(byte[] _data)
Called when the handler receive a request from the client. |
void |
run()
Runs the handler. |
void |
startHandler()
Starts the handler. |
void |
stopHandler()
Stops the handler. |
java.lang.String |
toString()
Returns a string representation of this ClientHandler. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private Server server
private java.io.BufferedReader in
private java.io.PrintWriter out
private volatile boolean running
private java.lang.Thread runner
private java.lang.String ip
private java.lang.String hostname
private java.net.Socket sock
| Constructor Detail |
public ClientHandlerImpl(java.net.Socket _sock,
Server _server)
_sock - The socket on wich the handler is attached._server - The server that is in charge of the handler.
public ClientHandlerImpl(java.net.Socket _sock,
Server _server,
int _timeout)
_sock - The socket on wich the handler is attached._server - The server that is in charge of the handler._timeout - The socket timeout, in millisecond.| Method Detail |
public void onRequest(byte[] _data)
throws java.lang.IllegalStateException,
InvalidRequestException
onRequest in interface ClientHandler_data - The data received from the client.
java.lang.IllegalStateException - If the handler is not running.
InvalidRequestException - If the request received from the client is not valid.Server.fireEvent(ServerEvent)
public void doRequest(byte[] _data)
throws java.lang.IllegalStateException,
InvalidRequestException
doRequest in interface ClientHandler_data - The answer to send to the client.
java.lang.IllegalStateException - If the handler is not running.
InvalidRequestException - If the request received from the client is not valid.public void startHandler()
startHandler in interface ClientHandlerpublic void stopHandler()
stopHandler in interface ClientHandlerpublic void run()
run in interface java.lang.Runnablepublic boolean isRunning()
isRunning in interface ClientHandlerboolean - True if the handler is running, false otherwise.public java.lang.String getClientHostAddress()
getClientHostAddress in interface ClientHandlerString - The client's IP, as a string.public java.lang.String getClientHostName()
getClientHostName in interface ClientHandlerString - The client's hostname.public java.lang.String toString()
toString in interface ClientHandlertoString in class java.lang.ObjectString - A string representation of this client handler.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||