19 #ifndef __MSGMANAGER_H__ 20 #define __MSGMANAGER_H__ 24 #include <csutil/ref.h> 48 #define NO_VALIDATION 0x00 51 #define REQUIRE_ANY_CLIENT 0x01 52 #define REQUIRE_READY_CLIENT 0x02 53 #define REQUIRE_ALREADY_READY_CLIENT 0x04 54 #define REQUIRE_ACTOR 0x08 55 #define REQUIRE_ALIVE 0x10 56 #define REQUIRE_TARGET 0x20 57 #define REQUIRE_TARGETACTOR 0x40 58 #define REQUIRE_TARGETNPC 0x80 105 template <
class SubClass>
128 CS::Threading::RecursiveMutexScopedLock lock(mutex);
129 if(!handlers.Contains(type))
131 GetEventManager()->Subscribe(
this, type, flags);
133 handlers.Put(type, fpt);
144 CS::Threading::RecursiveMutexScopedLock lock(mutex);
145 if(handlers.Contains(type))
147 handlers.DeleteAll(type);
148 return GetEventManager()->Unsubscribe(
this, type);
162 CS::Threading::RecursiveMutexScopedLock lock(mutex);
163 if(handlers.Contains(type))
165 handlers.Delete(type, handler);
166 if(!handlers.Contains(type))
168 return GetEventManager()->Unsubscribe(
this, type);
188 CS::Threading::RecursiveMutexScopedLock lock(mutex);
191 return GetEventManager()->UnsubscribeAll(
this);
204 csArray<FunctionPointer> msgHandlers;
206 CS::Threading::RecursiveMutexScopedLock lock(mutex);
207 msgHandlers = handlers.GetAll(msg->
GetType());
209 SubClass*
self =
dynamic_cast<SubClass*
>(
this);
216 for(
size_t i = 0; i < msgHandlers.GetSize(); ++i)
218 (
self->*msgHandlers[i])(msg, client);
223 CS::Threading::RecursiveMutex mutex;
236 CS_ASSERT(eventManager);
csArray< csString > DecodeCommandArea(Client *client, csString target)
Decodes an area: expression.
bool Unsubscribe(FunctionPointer handler, msgtype type)
Unsubscribes a specific handler from a specific message type.
gemObject * FindObjectByString(const csString &str, gemActor *me) const
Find the object we are referring to in str.
bool Unsubscribe(msgtype type)
Unsubscribes this manager from a specific message type.
virtual bool Verify(MsgEntry *pMsg, unsigned int flags, Client *&client)
The structure of 1 queue entry (pointer to a message)
void HandleMessage(MsgEntry *msg, Client *client)
Transfers the message to the manager specific function.
This interface must be implemented by objects that want to receive network messages.
void Subscribe(FunctionPointer fpt, msgtype type, uint32_t flags=0x01)
Subscribes this manager to a specific message type with a custom callback.
Any semi-autonomous object, either a player or an NPC.
Base server-side class for subscriptions.
EventManager * GetEventManager()
Returns the event manager.
virtual ~MessageManager()
Unsubscribes all messages then destroys this object.
This class collects data of a netclient.
A gemObject is any solid, graphical object visible in PS with normal physics and normal collision det...
This class holds the refs to the core factories, etc in CEL.
bool UnsubscribeAll()
Unsubscribes this manager from all message types.
This class handles all queueing and invoking of timed events, such as combat, spells, NPC dialog responses, range weapons, or NPC respawning.
Client * FindPlayerClient(const char *name)
Finds Client* of character with given name.
Provides a manager to facilitate subscriptions.