Planeshift
Public Types | Public Member Functions

MessageManager< SubClass > Class Template Reference

Provides a manager to facilitate subscriptions. More...

#include <msgmanager.h>

List of all members.

Public Types

typedef void(SubClass::* FunctionPointer )(MsgEntry *, Client *)

Public Member Functions

void HandleMessage (MsgEntry *msg, Client *client)
 Transfers the message to the manager specific function.
void Subscribe (FunctionPointer fpt, msgtype type, uint32_t flags=0x01)
 Subscribes this manager to a specific message type with a custom callback.
bool Unsubscribe (FunctionPointer handler, msgtype type)
 Unsubscribes a specific handler from a specific message type.
bool Unsubscribe (msgtype type)
 Unsubscribes this manager from a specific message type.
bool UnsubscribeAll ()
 Unsubscribes this manager from all message types.
virtual ~MessageManager ()
 Unsubscribes all messages then destroys this object.

Detailed Description

template<class SubClass>
class MessageManager< SubClass >

Provides a manager to facilitate subscriptions.

Any server-side class that needs to be informed of incoming messages should derive from this class. To use, simply inherit from this class with the template name being your class name.

Definition at line 104 of file msgmanager.h.


Member Typedef Documentation

template<class SubClass>
typedef void(SubClass::* MessageManager< SubClass >::FunctionPointer)(MsgEntry *, Client *)

Definition at line 107 of file msgmanager.h.


Constructor & Destructor Documentation

template<class SubClass>
virtual MessageManager< SubClass >::~MessageManager ( ) [inline, virtual]

Unsubscribes all messages then destroys this object.

Definition at line 110 of file msgmanager.h.


Member Function Documentation

template<class SubClass>
void MessageManager< SubClass >::HandleMessage ( MsgEntry msg,
Client client 
) [inline, virtual]

Transfers the message to the manager specific function.

Note:
DO NOT OVERRIDE
Parameters:
msgMessage that is forwarded to the manager's function
clientClient that is forwarded to the manager's function

Implements iNetSubscriber.

Definition at line 200 of file msgmanager.h.

template<class SubClass>
void MessageManager< SubClass >::Subscribe ( FunctionPointer  fpt,
msgtype  type,
uint32_t  flags = 0x01 
) [inline]

Subscribes this manager to a specific message type with a custom callback.

Any time a message with the specified type (and flags are met) is received the specified function is called

Parameters:
fptThe function to call
typeThe type of message to be notified of
flagsto check Default: 0x01

Definition at line 124 of file msgmanager.h.

template<class SubClass>
bool MessageManager< SubClass >::Unsubscribe ( msgtype  type) [inline]

Unsubscribes this manager from a specific message type.

Parameters:
typeThe type of message to unsubscribe from
Returns:
True if a subscription was removed, false if this was not subscribed

Definition at line 140 of file msgmanager.h.

template<class SubClass>
bool MessageManager< SubClass >::Unsubscribe ( FunctionPointer  handler,
msgtype  type 
) [inline]

Unsubscribes a specific handler from a specific message type.

Parameters:
handlerThe handler to unsubscribe
typeThe type of message to unsubscribe from
Returns:
True if a subscription was removed, false if this was not subscribed

Definition at line 158 of file msgmanager.h.

template<class SubClass>
bool MessageManager< SubClass >::UnsubscribeAll ( ) [inline]

Unsubscribes this manager from all message types.

Returns:
True if a subscription was removed, false if this was not subscribed

Definition at line 184 of file msgmanager.h.


The documentation for this class was generated from the following file: