|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.cscc.ClientConnectionManager
This is one of the two main classes (ServerConnectionManager
and ClientConnectionManager
) of the CSCC library
which helps to connect and to exchange the so-called data events between a
remote server and a client connected over a particular TCP/IP port.
A DataEvent
is an event which is the carrier for
particular data which is sent from the client to server or from server to
the client, respectively.
For doing so, a keep alive connection between the client and the server
is kept. The incoming messages are enqueued in a queue and can either be got
by a pull (the interessted clients have to go and look for the incoming data)
or a push (the interessted clients will be notified over a observer pattern)
mechanism.
2003-05-09 SM First Version 2003-05-14 SM working on additional methods and events, correction of some comments. 2003-05-16 SM Null pointer bug removed (when reading port number with closed connection) 2003-05-20 TR Comments corrected 2006-10-25 SM Comments revised.
Constructor Summary | |
ClientConnectionManager(int portNumber)
The constructor initializes this object. |
Method Summary | |
void |
addObserver(CommunicationEventObserver o)
An observer which wants to be notified about communication events can register itself at the communication observer list by this method. |
void |
addObserver(DataEventBaseObserver o)
This method adds an observer to the data event observer list. |
void |
close()
Closes the connection to the server. |
void |
closeConnection()
Deprecated. Don't use this method anymore, use close() instead! |
DataEvent |
getDataEvent()
This method returns the oldest DataEvent object received from the server. |
int |
getPortNumber()
This method returns the currently set port number. |
boolean |
hasDataEvents()
This method returns true, if any DataEvent objects are in the incoming data event queue. |
boolean |
isConnectionOpen()
This method returns true if the connection to the server is currently open. |
boolean |
open(java.lang.String serverName)
This method opens a new connection to a specified server. |
DataEvent |
receiveDataEvent()
This method returns the oldest DataEvent object in the incoming event queue. |
void |
removeDataEvent()
This method is used to remove manually the oldest event in the incoming event queue. |
void |
removeObserver(CommunicationEventObserver o)
An communication event observer which is already registered at the observer list can be unregisterd with this method. |
void |
removeObserver(DataEventBaseObserver o)
This method unregisters an observer from the data event observer list. |
void |
sendDataEvent(DataEvent de)
This method sends a DataEvent
object from the client to the server. |
void |
setPortNumber(int portNumber)
Sets the port number for a connection. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ClientConnectionManager(int portNumber)
open(String serverName)
.
The The client connection manager constructor take a port number
as argument which denotes on which port the connection is opened to
the server.portNumber
- Number of the TCP/IP port where the
connection should be established.
Method Detail |
public boolean open(java.lang.String serverName)
serverName
- Name of the server to which the connection
should be opened.
public void close()
public boolean isConnectionOpen()
public void sendDataEvent(DataEvent de)
DataEvent
object from the client to the server. This happens asynchronous,
i.e. the method returns immediately.de
- DataEvent object which should be sent to the server.
public DataEvent getDataEvent()
public void removeDataEvent()
public DataEvent receiveDataEvent()
public boolean hasDataEvents()
public void removeObserver(DataEventBaseObserver o)
o
- DataEventBaseObserver which should be removed from the observer
list.
public void removeObserver(CommunicationEventObserver o)
o
- CommunicationEventObserver which should be deleted from the
observer list.
public void addObserver(DataEventBaseObserver o)
o
- DataEventBaseObserver object which should be added to the
observer list.
public void addObserver(CommunicationEventObserver o)
CommunicationEventObserver
.o
- CommunicationEventObserver which wants to be notified if a new data
event from a client is received.
public void setPortNumber(int portNumber)
portNumber
- The TCP/IP port number which is used
to connect the next time to the server.
public int getPortNumber()
public void closeConnection()
close()
instead!
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |