|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This a simple interface to implements a network client. It is a quite simple class, but it is powerfull enough to realize any networking application.
Method Summary | |
void |
addClientListener(ClientListener _listener)
Adds a client listener to this class. |
void |
doRequest(byte[] _data)
Send an request to the server. |
void |
fireEvent(ClientEvent _evt)
Send a client event to the listeners |
java.net.InetAddress |
getInetAddress()
Returns the address of the server this client is bounded to. |
java.lang.String |
getInfo()
Returns the client's informations (port, address, version...). |
int |
getPort()
Returns the port on which this client is bounded to. |
java.lang.String |
getStatus()
Returns the client's status (state, ...). |
boolean |
isRunning()
Indicates if the client is running or not. |
void |
onRequest(byte[] _data)
Called when the client receive a request from the server. |
void |
removeAllClientListener()
Removes all the listeners associated with this class. |
void |
removeClientListener(ClientListener _listener)
Removes a specified client listener from the list. |
void |
setInetAddress(java.net.InetAddress _address)
Changes the server's address. |
void |
setPort(int _port)
Changes the client's port. |
void |
setSocketFactory(javax.net.SocketFactory _factory)
Sets the SocketFactory. |
void |
startClient()
Starts the client. |
void |
stopClient()
Stops the client. |
java.lang.String |
toString()
Returns a string representation of this client. |
Methods inherited from interface java.lang.Runnable |
run |
Method Detail |
public void onRequest(byte[] _data) throws java.lang.IllegalStateException, InvalidRequestException
_data
- The data received from the server.
java.lang.IllegalStateException
- If the client is not running.
InvalidRequestException
- If the request received from the server is not valid.fireEvent(ClientEvent)
public void doRequest(byte[] _data) throws java.lang.IllegalStateException, InvalidRequestException
_data
- The answer to send to the server.
java.lang.IllegalStateException
- If the client is not running.
InvalidRequestException
- If the request received from the server is not valid.public void startClient()
public void stopClient()
public boolean isRunning()
boolean
- True if the client is running, false otherwise.public void setSocketFactory(javax.net.SocketFactory _factory) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
_factory
- The socket factory.
java.lang.IllegalStateException
- If the client is running.
java.lang.IllegalArgumentException
- If the SocketFactory is not valid or has not been initialized.public void addClientListener(ClientListener _listener)
_listener
- The Listener to add.public void removeClientListener(ClientListener _listener)
_listener
- The Listener to remove.public void removeAllClientListener()
public void fireEvent(ClientEvent _evt)
_evt
- The event to be fired.public java.lang.String getInfo()
String
- The client's informations.public java.lang.String getStatus()
String
- The client's status.public int getPort()
int
- The port number to which this client is bounded to.public java.lang.String toString()
toString
in class java.lang.Object
String
- A string representation of this client.public void setPort(int _port) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
_port
- The new client's port.
java.lang.IllegalStateException
- If the client is running.
java.lang.IllegalArgumentException
- If the port is not valid.public java.net.InetAddress getInetAddress()
InetAddress
- A InetAddress representing the address of the server this client is bouded to.public void setInetAddress(java.net.InetAddress _address) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
_address
- The new server's address.
java.lang.IllegalStateException
- If the client is running.
java.lang.IllegalArgumentException
- If the address is not valid.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |