net.directj.csf
Interface ClientHandler

All Superinterfaces:
java.lang.Runnable
All Known Implementing Classes:
ClientHandlerImpl, JLoggerClientHandler

public interface ClientHandler
extends java.lang.Runnable

This class is in charge of a client connection. It allow the user to handle request and to do answer to the distant machine the handler is bouded to.

Version:
0.1.2
Author:
CARTAPANIS Alexandre <earendil@jprolog.net>
See Also:
ServerEvent.getHandler()

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 startHandler()
          Starts the handler.
 void stopHandler()
          Stops the handler.
 java.lang.String toString()
          Returns a string representation of this ClientHandler.
 
Methods inherited from interface java.lang.Runnable
run
 

Method Detail

onRequest

public void onRequest(byte[] _data)
               throws java.lang.IllegalStateException,
                      InvalidRequestException
Called when the handler receive a request from the client. In fact, this must fire a ServerEvent and use the server's fireEvent method.

Parameters:
_data - The data received from the client.
Throws:
java.lang.IllegalStateException - If the handler is not running.
InvalidRequestException - If the request received from the client is not valid.
See Also:
Server.fireEvent(ServerEvent)

doRequest

public void doRequest(byte[] _data)
               throws java.lang.IllegalStateException,
                      InvalidRequestException
Send an request to the client.

Parameters:
_data - The answer to send to the client.
Throws:
java.lang.IllegalStateException - If the handler is not running.
InvalidRequestException - If the request received from the client is not valid.

stopHandler

public void stopHandler()
Stops the handler.


startHandler

public void startHandler()
Starts the handler.


isRunning

public boolean isRunning()
Indicates if the handler is running or not.

Returns:
boolean - True if the handler is running, false otherwise.

getClientHostAddress

public java.lang.String getClientHostAddress()
Returns the client's IP. It is the IP of the distant machine that this client handler is bounded to.

Returns:
String - The client's IP, as a string.

getClientHostName

public java.lang.String getClientHostName()
Returns the client's hostname. It is the hostname of the distant machine that this client handler is bounded to.

Returns:
String - The client's hostname.

toString

public java.lang.String toString()
Returns a string representation of this ClientHandler.

Overrides:
toString in class java.lang.Object
Returns:
String - A string representation of this client handler.


Copyright 2002 CARTAPANIS Alexandre
This page was last updated on May 10 2003