|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This a simple interface to implements a network server. It is a quite simple class, but it is powerfull enough to realize any networking application.
Method Summary | |
void |
addServerListener(ServerListener _listener)
Adds a server listener to this class. |
void |
fireEvent(ServerEvent _evt)
Send a server event to the listeners |
java.net.InetAddress |
getInetAddress()
Returns the address of the endpoint this server is listening to. |
java.lang.String |
getInfo()
Returns the server's informations (port, address, version...). |
int |
getMaximumClient()
Returns the maximum amount of client the server can handle. |
java.lang.String |
getName()
Returns the server's name. |
int |
getPort()
Returns the port on which this server is listening. |
java.lang.String |
getStatus()
Returns the server's status (state, number of connection, ...). |
boolean |
isRunning()
Indicates if the server is running or not. |
void |
killClient(java.lang.String _address)
Kills a client identified by his hostname or IP address. |
void |
removeAllServerListener()
Removes all the listeners associated with this class. |
void |
removeServerListener(ServerListener _listener)
Removes a specified server listener from the list. |
void |
setClientHandlerFactory(ClientHandlerFactory _factory)
Sets the ClientHandlerFactory. |
void |
setInetAddress(java.net.InetAddress _address)
Changes the server's address. |
void |
setMaximumClient(int _max)
Changes the server's maximum client amount. |
void |
setName(java.lang.String _name)
Changes the server's name. |
void |
setPort(int _port)
Changes the server's port. |
void |
setServerSocketFactory(javax.net.ServerSocketFactory _factory)
Sets the ServerSocketFactory. |
void |
startServer()
Starts the server. |
void |
stopServer()
Stops the server. |
java.lang.String |
toString()
Returns a string representation of this server. |
Methods inherited from interface java.lang.Runnable |
run |
Method Detail |
public void startServer()
public void stopServer()
public boolean isRunning()
boolean
- True if the server is running and ready to accept client, false otherwise.public void killClient(java.lang.String _address)
_address
- The address of the client we want to kill.public void setClientHandlerFactory(ClientHandlerFactory _factory) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
_factory
- The client handler factory.
java.lang.IllegalStateException
- If the server is running.
java.lang.IllegalArgumentException
- If the ClientHandlerFactory is not valid or has not been initialized.public void setServerSocketFactory(javax.net.ServerSocketFactory _factory) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
_factory
- The server socket factory.
java.lang.IllegalStateException
- If the server is running.
java.lang.IllegalArgumentException
- If the ServerSocketFactory is not valid or has not been initialized.public void addServerListener(ServerListener _listener)
_listener
- The Listener to add.public void removeServerListener(ServerListener _listener)
_listener
- The Listener to remove.public void removeAllServerListener()
public void fireEvent(ServerEvent _evt)
_evt
- The event to be fired.public java.lang.String getInfo()
String
- The server's informations.public java.lang.String getStatus()
String
- The server's status.public int getPort()
int
- The port number to which this server is listening.public void setPort(int _port) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
_port
- The new server's port.
java.lang.IllegalStateException
- If the server is running.
java.lang.IllegalArgumentException
- If the port is not valid.public java.net.InetAddress getInetAddress()
InetAddress
- A InetAddress representing the local endpoint of this server.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 server is running.
java.lang.IllegalArgumentException
- If the address is not valid.public java.lang.String getName()
String
- The server's name.public void setName(java.lang.String _name) throws java.lang.IllegalStateException
_name
- The new server's name.
java.lang.IllegalStateException
- If the server is running.public int getMaximumClient()
int
- The maximum client amount.public void setMaximumClient(int _max) throws java.lang.IllegalArgumentException
_max
- The new maximum client amount.
java.lang.IllegalArgumentException
- If the specified number is not valid.public java.lang.String toString()
toString
in class java.lang.Object
String
- A string representation of this server.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |