class MessageDispatcher

A message dispatching hub. More...

Full nameTelEngine::MessageDispatcher
Definition#include <telengine.h>
InheritsTelEngine::GenObject [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

The dispatcher class is a hub that holds a list of handlers to be called for the messages that pass trough the hub. It can also handle a queue of messages that are typically dispatched by a separate thread.

 MessageDispatcher ()

MessageDispatcher

Creates a new message dispatcher.

 ~MessageDispatcher ()

~MessageDispatcher

Destroys the dispatcher and the installed handlers.

bool  install (MessageHandler *handler)

install

Installs a handler in the dispatcher.

Parameters:
handlerA pointer to the handler to install

Returns: True on success, false on failure

bool  uninstall (MessageHandler *handler)

uninstall

Uninstalls a handler from the dispatcher.

Parameters:
handlerA pointer to the handler to uninstall

Returns: True on success, false on failure

bool  dispatch (Message &msg)

dispatch

Dispatch a message to the installed handlers

Parameters:
msgThe message to dispatch

Returns: True if one handler accepted it, false if all ignored

inline unsigned int  queueLength ()

queueLength

[const]

Get the number of messages waiting in the queue

Returns: Count of messages in the queue

bool  enqueue (Message *msg)

enqueue

Put a message in the waiting queue

Parameters:
msgThe message to enqueue, will be destroyed after dispatching

Returns: True if successfully queued, false otherwise

void  dequeue ()

dequeue

Dispatch all messages from the waiting queue

bool  dequeueOne ()

dequeueOne

Dispatch one message from the waiting queue

Returns: True if success, false if the queue is empty

inline void  clear ()

clear

Clear all the message handlers

inline void  setHook (void (*hookFunc)(Message &, bool) = 0)

setHook

Install or remove a hook to catch messages after being dispatched

Parameters:
hookFuncPointer to a callback function


Generated by: kk on nyx on Sat Jun 4 19:29:41 2005, using kdoc 2.0a54.