Planeshift
|
Provides a manager to facilitate subscriptions. More...
#include <msgmanager.h>
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. |
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.
typedef void(SubClass::* MessageManager< SubClass >::FunctionPointer)(MsgEntry *, Client *) |
Definition at line 107 of file msgmanager.h.
virtual MessageManager< SubClass >::~MessageManager | ( | ) | [inline, virtual] |
Unsubscribes all messages then destroys this object.
Definition at line 110 of file msgmanager.h.
void MessageManager< SubClass >::HandleMessage | ( | MsgEntry * | msg, |
Client * | client | ||
) | [inline, virtual] |
Transfers the message to the manager specific function.
msg | Message that is forwarded to the manager's function |
client | Client that is forwarded to the manager's function |
Implements iNetSubscriber.
Definition at line 200 of file msgmanager.h.
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
fpt | The function to call |
type | The type of message to be notified of |
flags | to check Default: 0x01 |
Definition at line 124 of file msgmanager.h.
bool MessageManager< SubClass >::Unsubscribe | ( | msgtype | type | ) | [inline] |
Unsubscribes this manager from a specific message type.
type | The type of message to unsubscribe from |
Definition at line 140 of file msgmanager.h.
bool MessageManager< SubClass >::Unsubscribe | ( | FunctionPointer | handler, |
msgtype | type | ||
) | [inline] |
Unsubscribes a specific handler from a specific message type.
handler | The handler to unsubscribe |
type | The type of message to unsubscribe from |
Definition at line 158 of file msgmanager.h.
bool MessageManager< SubClass >::UnsubscribeAll | ( | ) | [inline] |
Unsubscribes this manager from all message types.
Definition at line 184 of file msgmanager.h.