Planeshift
MessageManager< SubClass > Class Template Reference

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. More...
 
void Subscribe (FunctionPointer fpt, msgtype type, uint32_t flags=0x01)
 Subscribes this manager to a specific message type with a custom callback. More...
 
bool Unsubscribe (msgtype type)
 Unsubscribes this manager from a specific message type. More...
 
bool Unsubscribe (FunctionPointer handler, msgtype type)
 Unsubscribes a specific handler from a specific message type. More...
 
bool UnsubscribeAll ()
 Unsubscribes this manager from all message types. More...
 
virtual ~MessageManager ()
 Unsubscribes all messages then destroys this object. More...
 
- Public Member Functions inherited from MessageManagerBase
csArray< csString > DecodeCommandArea (Client *client, csString target)
 Decodes an area: expression. More...
 
gemObjectFindObjectByString (const csString &str, gemActor *me) const
 Find the object we are referring to in str. More...
 
ClientFindPlayerClient (const char *name)
 Finds Client* of character with given name. More...
 
virtual bool Verify (MsgEntry *pMsg, unsigned int flags, Client *&client)
 

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 106 of file msgmanager.h.

Member Typedef Documentation

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

Definition at line 109 of file msgmanager.h.

Constructor & Destructor Documentation

template<class SubClass>
virtual MessageManager< SubClass >::~MessageManager ( )
inlinevirtual

Unsubscribes all messages then destroys this object.

Definition at line 112 of file msgmanager.h.

Member Function Documentation

template<class SubClass>
void MessageManager< SubClass >::HandleMessage ( MsgEntry msg,
Client client 
)
inlinevirtual

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 202 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 126 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 142 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 160 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 186 of file msgmanager.h.


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