|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.kaariboga.io.DeliveryService
The DeliveryService receives messages and dispatches them to other bases. At the moment messages are delivered using TCP/IP socket connections, but it future other connections or protocols may be supported. For example a DeliveryService might use HTTP to tunnel through a firewall.
Field Summary | |
(package private) ListenThread |
listenThread
Thread listening for incoming messages |
protected int |
port
Port on which this service receives messages |
protected java.util.LinkedList |
receivingThreads
List of all threads currently receiving messages |
protected java.util.LinkedList |
sendingThreads
List of all threads currently sending messages |
protected KbMessageHandler |
user
This user is contacted in case something goes wrong with a posted message. |
Fields inherited from interface org.kaariboga.io.KbMessageHandler |
AGENT_NOT_REACHABLE, BASE_NOT_REACHABLE, BASE_OFFLINE |
Constructor Summary | |
DeliveryService(KbMessageHandler user,
int port)
Creates a new delivery service. |
Method Summary | |
void |
goOffline()
Removes connection to the internet. |
void |
goOnline()
Connects to the internet. |
void |
handleMessage(KaaribogaMessage message)
Called by a receiving thread when a message has arrived. |
void |
messageDeliveryError(int errorCode,
KaaribogaMessage message)
Called in case a message could not be delivered. |
void |
postMessage(KaaribogaMessage message)
Delivers this message to the destination. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected KbMessageHandler user
protected int port
protected java.util.LinkedList sendingThreads
protected java.util.LinkedList receivingThreads
ListenThread listenThread
Constructor Detail |
public DeliveryService(KbMessageHandler user, int port)
user
- A user of this service, who receives error messages.port
- The network port, this receiver should listen on.Method Detail |
public void postMessage(KaaribogaMessage message)
message
- The message, which should be transfered. The message
allready contains sender and recipient.public void handleMessage(KaaribogaMessage message)
handleMessage
in interface KbMessageHandler
message
- The message, that has arrived.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 goOnline()
public void goOffline()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |