|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.kaariboga.domainserver.DomainServer
A class to build up domains for kaariboga servers. This class manages a list of all servers connected to the domain and provides the means for other servers to get this information. In addition, an agent server may use this domain server to determine it's own IP address. Servers who get their IP address dynamically may have problems of determing their own address, because in pure Java it is not possible to get the IP address for a specific device. Incoming Messages: BASE_ONLINE sent by an agent server when the agent server wants to connect to this domain. BASE_OFFLINE sent by an agent server when the agent server wants to disconnect from this domain. GET_BASES sent by an agent server to get a list of all servers connected to this domain. GET_MY_IP_ADDRESS sent by an agent server, who wants to know it's own IP address. This is useful for servers who get their IP address dynamically. Outgoing Messages: BASES sent by this server to nodify an agent server of all other servers connected. YOUR_IP_ADDRESS sent by this server as an respond to GET_MY_IP_ADDRESS
Field Summary | |
(package private) KaaribogaAddress |
address
Address of this server |
(package private) java.util.Hashtable |
baseEntries
Bases connected to this domain plus some extra information |
(package private) java.util.Hashtable |
bases
Bases connected to this domain |
(package private) DeliveryService |
deliveryService
Service for message transportation across network |
(package private) long |
interval
time interval in millis after which old entries are deleted |
(package private) int |
port
port on which to listen |
(package private) SimpleTimer |
timer
timer, that triggers cleaning of old entries. |
Fields inherited from interface org.kaariboga.io.KbMessageHandler |
AGENT_NOT_REACHABLE, BASE_NOT_REACHABLE, BASE_OFFLINE |
Constructor Summary | |
DomainServer(int port,
long interval)
|
Method Summary | |
protected void |
addBase(java.lang.String hashcode,
KaaribogaAddress base)
Adds a new KaaribogaBase to this domain |
void |
handleMessage(KaaribogaMessage message)
Called when a message for the DeliveryServiceUser has arrived. |
void |
messageDeliveryError(int errorCode,
KaaribogaMessage message)
Called in case a message could not be delivered. |
void |
onSimpleTimer()
Removes old base entries from the list of bases connected to the domain. |
protected void |
removeBase(java.lang.String hashcode)
Removes a base from this domain. |
void |
sendBasesList(KaaribogaAddress receiver)
Sends a list of all bases connected to the domain to a specified server. |
void |
terminate()
terminates this server |
Methods inherited from class java.lang.Object |
|
Field Detail |
int port
KaaribogaAddress address
DeliveryService deliveryService
long interval
SimpleTimer timer
java.util.Hashtable baseEntries
java.util.Hashtable bases
Constructor Detail |
public DomainServer(int port, long interval)
port
- port on which to listenMethod Detail |
public void handleMessage(KaaribogaMessage message)
handleMessage
in interface KbMessageHandler
message
- The message, that has arrived for the user.public void messageDeliveryError(int errorCode, KaaribogaMessage message)
messageDeliveryError
in interface KbMessageHandler
errorCode
- Delivery error code. At the moment the following codes exit:
BASE_NOT_REACHABLE, AGENT_NOT_REACHABLE, BASE_OFFLINEmessage
- The message, that could not be delivered.
Note, that this may be null if the message no longer exists on
the sending host. Future versions of KaaribogaMessage may include
a global unique identifier.public void onSimpleTimer()
onSimpleTimer
in interface SimpleTimerListener
public void terminate()
protected void addBase(java.lang.String hashcode, KaaribogaAddress base)
hashcode
- Hashcode, that should be used to store the base.base
- KaaribogaBase to addprotected void removeBase(java.lang.String hashcode)
hashcode
- Hashcode, that should be used to store the base.public void sendBasesList(KaaribogaAddress receiver)
receiver
- the server that receives the list
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |