Home Previous Up Next Index

Mailbox

Overview

class Mailbox

Facilitates read/write operations on messages The mailbox can be used in either a pull or push mode, i.e. clients of the mailbox may register an event_listener which will push new messages as they are received. Alternatively clients may choose to poll the mailbox for new messages.

Operation Index

empty
If the mailbox has pending messages this return false
active
Returns true if mailbox is still in service
read
Returns the first unread message in the mailbox Will throw an exception if (empty() == true)
write
Posts a message via the mailbox May throw an exception if (active() == false)
addListener
Registers an event_listener with the mailbox The mailbox will trigger the on_event message of the listener each time a new message is received with an event_type of "message".
removeListener
Unregisters an EventListener

Operations

bool empty()

If the mailbox has pending messages this return false

bool active()

Returns true if mailbox is still in service

string read() throws MattNoMessageException, MattNotActiveException

Returns the first unread message in the mailbox Will throw an exception if (empty() == true)

void write(string message) throws MattNotActiveException

Posts a message via the mailbox May throw an exception if (active() == false)

void addListener(EventListener* listener) throws MattAlreadyListeningException, MattListenException, MattNotActiveException

Registers an event_listener with the mailbox The mailbox will trigger the on_event message of the listener each time a new message is received with an event_type of "message". If the mailbox is closed gracefully the listener will also be informed with a "closed" event message. A mailbox will support no more than one event_listener per client. If calling listener->on_event(...) fails the mailbox will assume the client is no longer available and the mailbox will close.

void removeListener() throws MattNotListeningException, MattListenException, MattNotActiveException

Unregisters an EventListener


Home Previous Up Next Index