|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Observable | +--com.lloseng.ocsf.client.ObservableClient
This class acts as a subclass of AbstractClient
and is also an Observable
class.
Each time a new message is received, observers are notified.
Field Summary | |
static java.lang.String |
CONNECTION_CLOSED
Indicates a close of the connection to server. |
static java.lang.String |
CONNECTION_ESTABLISHED
Indicates establishment of a connection to server. |
Constructor Summary | |
ObservableClient(java.lang.String host,
int port)
|
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 raised by the client listening thread. |
java.lang.String |
getHost()
|
java.net.InetAddress |
getInetAddress()
|
int |
getPort()
|
protected void |
handleMessageFromServer(java.lang.Object message)
This method is used to handle messages from the server. |
boolean |
isConnected()
Used to find out if the client is connnected. |
void |
openConnection()
Opens the connections with 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.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String CONNECTION_CLOSED
public static final java.lang.String CONNECTION_ESTABLISHED
Constructor Detail |
public ObservableClient(java.lang.String host, int port)
Method Detail |
public final void openConnection() throws java.io.IOException
java.io.IOException
public final void closeConnection() throws java.io.IOException
java.io.IOException
public final void sendToServer(java.lang.Object msg) throws java.io.IOException
msg
- The message to be sent.
java.io.IOException
public final boolean isConnected()
public final int getPort()
public final void setPort(int port)
port
- the port number.public final java.lang.String getHost()
public final void setHost(java.lang.String host)
host
- the host name.public final java.net.InetAddress getInetAddress()
protected void handleMessageFromServer(java.lang.Object message)
message
- The message received from the client.protected void connectionClosed()
protected void connectionException(java.lang.Exception exception)
exception
- the exception raised.protected void connectionEstablished()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |