org.robokind.api.messaging
Interface MessageBlockingReceiver<Msg>

Type Parameters:
Msg - type of Message to return
All Known Implementing Classes:
DefaultMessageBlockingReceiver

public interface MessageBlockingReceiver<Msg>

Synchronous message receiver. Uses a RecordBlockingReceiver to wait for a Record. Uses an Adapter to adapt Records to Messages.

Author:
Matthew Stevenson

Method Summary
 void addMessageListener(Listener<Msg> listener)
          Adds a Listener to be notified when a Message has been received.
 int clearMessages()
          Removes any pending messages for this receiver.
 Msg fetchMessage(long timeout)
          Blocks while waiting for a Message.
 void removeMessageListener(Listener<Msg> listener)
          Removes a Listener from being notified.
 void start()
          Initializes and connects the MessageAsyncReceiver, and begins receiving Messages.
 void stop()
          Stops the MessageAsyncReceiver, making it unable to receive Messages.
 

Method Detail

start

void start()
           throws Exception
Initializes and connects the MessageAsyncReceiver, and begins receiving Messages.

Throws:
Exception - if there is an error starting

stop

void stop()
Stops the MessageAsyncReceiver, making it unable to receive Messages.


fetchMessage

Msg fetchMessage(long timeout)
Blocks while waiting for a Message.

Parameters:
timeout - timeout length in milliseconds
Returns:
Message received from a MessageSender, null if no Message received before timeout

clearMessages

int clearMessages()
Removes any pending messages for this receiver. Returns the number of messages cleared.

Returns:
number of messages cleared

addMessageListener

void addMessageListener(Listener<Msg> listener)
Adds a Listener to be notified when a Message has been received.

Parameters:
listener - the Listener to be notified

removeMessageListener

void removeMessageListener(Listener<Msg> listener)
Removes a Listener from being notified.

Parameters:
listener - the Listener to remove


Copyright © 2011-2012. All Rights Reserved.