|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ocsf.client.AbstractClient
The AbstractClient
contains all the
* methods necessary to set up the client side of a client-server
* architecture. When a client is thus connected to the
* server, the two programs can then exchange Object
* instances.
*
* Method handleMessageFromServer
must be defined by
* a concrete subclass. Several other hook methods may also be
* overriden.
* * Several public service methods are provided to * application that use this framework.
* * Project Name: OCSF (Object Client-Server Framework)
* * @author Dr. Robert Laganière * @author Dr. Timothy C. Lethbridge * @author François Bél;langer * @author Paul Holden * @version February 2001 (2.12)
Constructor Summary | |
AbstractClient(java.lang.String host,
int port)
Constructs the client. |
Method Summary | |
void |
closeConnection()
Closes the connection to the server. |
protected void |
connectionClosed()
Hook method called after the connection has been closed. |
protected void |
connectionEstablished()
Hook method called after a connection has been established. |
protected void |
connectionException(java.lang.Exception exception)
Hook method called each time an exception is thrown by the * client's thread that is waiting for messages from the server. |
java.lang.String |
getHost()
|
java.net.InetAddress |
getInetAddress()
returns the client's description. |
int |
getPort()
|
protected abstract void |
handleMessageFromServer(java.lang.Object msg)
Handles a message sent from the server to this client. |
boolean |
isConnected()
|
void |
openConnection()
Opens the connection with the server. |
void |
run()
Waits for messages from the server. |
void |
sendToServer(java.lang.Object msg)
Sends an object to the server. |
void |
setHost(java.lang.String host)
Sets the server host for the next connection. |
void |
setPort(int port)
Sets the server port number for the next connection. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AbstractClient(java.lang.String host, int port)
Method Detail |
public final void openConnection() throws java.io.IOException
java.io.IOException
public final void sendToServer(java.lang.Object msg) throws java.io.IOException
java.io.IOException
public final void closeConnection() throws java.io.IOException
java.io.IOException
public final boolean isConnected()
public final int getPort()
public final void setPort(int port)
public final java.lang.String getHost()
public final void setHost(java.lang.String host)
public final java.net.InetAddress getInetAddress()
public final void run()
handleMessageFromServer()
.
* Not to be explicitly called.
run
in interface java.lang.Runnable
protected void connectionClosed()
protected void connectionException(java.lang.Exception exception)
protected void connectionEstablished()
protected abstract void handleMessageFromServer(java.lang.Object msg)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |