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

Type Parameters:
Msg - type of Message to return
All Superinterfaces:
org.jflux.api.core.Source<Msg>
All Known Implementing Classes:
DefaultMessageBlockingReceiver

public interface MessageBlockingReceiver<Msg>
extends org.jflux.api.core.Source<Msg>

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

Author:
Matthew Stevenson

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

Field Detail

DEFAULT_TIMEOUT_LENGTH

static final int DEFAULT_TIMEOUT_LENGTH
See Also:
Constant Field Values
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.


getValue

Msg getValue()
Blocks while waiting for a Message.

Specified by:
getValue in interface org.jflux.api.core.Source<Msg>
Returns:
Message received from a MessageSender, null if no Message received before timeout

setTimeout

void setTimeout(long timeout)

getTimeout

long getTimeout()

clearMessages

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

Returns:
number of messages cleared

addMessageListener

void addMessageListener(org.jflux.api.core.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(org.jflux.api.core.Listener<Msg> listener)
Removes a Listener from being notified.

Parameters:
listener - the Listener to remove


Copyright © 2011-2013. All Rights Reserved.