|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.cscc.ServerConnectionManager
This is the server class of the two main classes
ServerConnectionManager
and
ClientConnectionManager
in
this client server communication component.
This class provides the functionality to connect and to exchange
so-called data events between a remote server and a client over a specific
TCP/IP port. A DataEvent
is an event which
sends specific data from a client to server, respectively from a server
to the client.
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 be either get by
a pull (the interested clients have to go and look for the data) or a push
(the interested clients will be notified over a oberver pattern) mechanism.
2003-05-09 SM First Version 2003-05-14 SM working on additional methods and events, correction of some comments. 2003-05-15 SM methods for setting and getting port number / Completion of method comments. 2003-05-17 SM Comments corrected 2003-05-20 TR Comments corrected 2003-06-23 SM Dispose method corrected, stops now the port listening thread. 2003-06-24 SM Some corrections of comments. 2004-12-13 SM Some cleaning of unused things. 2006-11-28 SM Comments revised.
Constructor Summary | |
ServerConnectionManager(int portNumber)
This constructor initializes the server connection manager. |
Method Summary | |
void |
addObserver(CommunicationEventObserver o)
An observer which wants to be notified about communication events can register itself at the communication observer list. |
void |
addObserver(DataEventBaseObserver o)
An observer which wants to be notified about new messages from clients can register itself at the observer list. |
void |
beginListening()
This method is used to start the listening process of the server. |
void |
closeAllConnections()
Closes all (currently active, ie. open) connections to the currently subscribed clients. |
void |
closeConnection(java.lang.Object clientId)
Closes a connection to a client. |
void |
dispose()
Releases all occupied ressources by this component, i.e. all the connections are closed, the listening on the TCP/IP port is stopped and the internally used threads are stopped. |
DataEvent |
getDataEvent()
This method returns the oldest DataEvent object received from the server. |
int |
getPortNumber()
Gets the currently set port number. |
boolean |
hasDataEvents()
This method returns true, if there are data events in the incoming event queue. |
DataEvent |
receiveDataEvent()
This method returns the oldest DataEvent object in the queue. |
void |
removeDataEvent()
This method is used to remove manually the oldest event in the incoming event queue. |
void |
removeObserver(CommunicationEventObserver o)
A communication observer which is already registered at the observer list, can be unregisterd with this method. |
void |
removeObserver(DataEventBaseObserver o)
A data observer which is already registered at the observer list can be unregisterd with this method. |
void |
sendBroadCastEvent(DataEvent de)
This method broadcasts an event to all connected clients. |
void |
sendDataEvent(DataEvent de,
java.lang.Object clientId)
This method sends a DataEvent object to a specific client having a given clientId. |
void |
setPortNumber(int portNumber)
Sets the port number for the connection. |
void |
stopListening()
This method stops the listener, listening for connection requests. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ServerConnectionManager(int portNumber)
portNumber
- TCP/IP port where to listen for connection requests
Method Detail |
public void stopListening()
public void sendDataEvent(DataEvent de, java.lang.Object clientId)
de
- DataEvent object which should be sent to the client.clientId
- Id of the client which should receive the data event.
public DataEvent receiveDataEvent()
public DataEvent getDataEvent()
public void removeDataEvent()
public boolean hasDataEvents()
public void sendBroadCastEvent(DataEvent de)
de
- DataEvent object which should be broadcasted to all clients.
public void addObserver(DataEventBaseObserver o)
DataEventObserver
or DataEventReceivingObserver
,
which are subinterfaces of DataEventBaseObserver
.o
- DataEventBaseObserver which wants to be notified if a new data
event from a client is received.
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 removeObserver(CommunicationEventObserver o)
o
- CommunicationEventObserver which should be deleted from the
observer list.
public void removeObserver(DataEventBaseObserver o)
o
- DataEventBaseObserver which should be deleted from the
observer list.
public void beginListening()
getPortNumber()
for
connection requests of the client.
public void setPortNumber(int portNumber)
beginListening()
is called.portNumber
- Number to use as port
public int getPortNumber()
public void dispose()
public void closeConnection(java.lang.Object clientId)
clientId
- Identification object, which identifies the client
connection uniquely.
public void closeAllConnections()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |