Planeshift
|
This class is the client's and server's main interface for either sending network messages out or getting notified about inbound ones which have been received. More...
#include <msghandler.h>
Public Types | |
typedef NetBase::broadcasttype | broadcasttype |
import the broadcasttype | |
Public Member Functions | |
void | AddToLocalQueue (MsgEntry *me) |
virtual void | Broadcast (MsgEntry *msg, broadcasttype scope=NetBase::BC_EVERYONEBUTSELF, int guildID=-1) |
Send messages to many clients with one func call. | |
bool | Flush () |
Flush the connected output queue. | |
csTicks | GetPing () |
bool | Initialize (NetBase *nb, int queuelen=500) |
Initializes the Handler. | |
MsgHandler () | |
virtual void | Multicast (MsgEntry *msg, csArray< PublishDestination > &multi, uint32_t except, float range) |
Sends the given message me to all the clients in the list. | |
void | Publish (MsgEntry *msg) |
Distribute message to all subscribers. | |
virtual void | SendMessage (MsgEntry *msg) |
Allows subscribers to respond with new messages. | |
virtual void | Subscribe (iNetSubscriber *subscriber, msgtype type, uint32_t flags=0x01) |
Subscribes an iNetSubscriber to a specific message type. | |
virtual bool | Unsubscribe (iNetSubscriber *subscriber, msgtype type) |
Unsubscribes a subscriber from a specific message type. | |
virtual bool | UnsubscribeAll (iNetSubscriber *subscriber) |
Searches all message types and deletes any Subscription that has the specified subscriber. | |
virtual | ~MsgHandler () |
Protected Attributes | |
CS::Threading::ReadWriteMutex | mutex |
Protects subscribers. | |
NetBase * | netbase |
MsgQueue * | queue |
csHash< Subscription, msgtype > | subscribers |
Stores the hash of all subscribers and the message type they are subscribed to. |
This class is the client's and server's main interface for either sending network messages out or getting notified about inbound ones which have been received.
Definition at line 106 of file msghandler.h.
import the broadcasttype
Definition at line 150 of file msghandler.h.
MsgHandler::MsgHandler | ( | ) |
virtual MsgHandler::~MsgHandler | ( | ) | [virtual] |
void MsgHandler::AddToLocalQueue | ( | MsgEntry * | me | ) | [inline] |
Definition at line 179 of file msghandler.h.
virtual void MsgHandler::Broadcast | ( | MsgEntry * | msg, |
broadcasttype | scope = NetBase::BC_EVERYONEBUTSELF , |
||
int | guildID = -1 |
||
) | [inline, virtual] |
Send messages to many clients with one func call.
Definition at line 157 of file msghandler.h.
bool MsgHandler::Flush | ( | ) | [inline] |
Flush the connected output queue.
Definition at line 184 of file msghandler.h.
csTicks MsgHandler::GetPing | ( | ) | [inline] |
Definition at line 181 of file msghandler.h.
virtual void MsgHandler::Multicast | ( | MsgEntry * | msg, |
csArray< PublishDestination > & | multi, | ||
uint32_t | except, | ||
float | range | ||
) | [inline, virtual] |
Sends the given message me to all the clients in the list.
Sends the given message me to all the clients in the list (clientlist) which is of size count. This will send the message to all the clients except the client which has a client number given in the variable except.
msg | Is the message to be sent to other clients. |
multi | Is a vector of all the clients to send this message to. |
except | Is a client number for a client NOT to send this message to. This would usually be the client trying to send the message. |
range | Is the maximum distance the client must be away to be out of "message reception range". |
Definition at line 176 of file msghandler.h.
void MsgHandler::Publish | ( | MsgEntry * | msg | ) |
Distribute message to all subscribers.
virtual void MsgHandler::SendMessage | ( | MsgEntry * | msg | ) | [inline, virtual] |
Allows subscribers to respond with new messages.
Reimplemented in ClientMsgHandler.
Definition at line 153 of file msghandler.h.
virtual void MsgHandler::Subscribe | ( | iNetSubscriber * | subscriber, |
msgtype | type, | ||
uint32_t | flags = 0x01 |
||
) | [virtual] |
Subscribes an iNetSubscriber to a specific message type.
Subclasses of iNetSubscriber subscribe to incoming network messages using this function. Adds the resulting Subscription to subscribers.
subscriber | The subscriber that wants to be informed of messages |
type | The type of message to monitor |
flags | Additional flags to determine if the message should be forwarded |
virtual bool MsgHandler::Unsubscribe | ( | iNetSubscriber * | subscriber, |
msgtype | type | ||
) | [virtual] |
Unsubscribes a subscriber from a specific message type.
If subscribers contains a Subscription that has the specified subscriber and the message type key it is removed and true is returned
subscriber | The subscriber to look for in the hash |
type | The type of message to search |
virtual bool MsgHandler::UnsubscribeAll | ( | iNetSubscriber * | subscriber | ) | [virtual] |
Searches all message types and deletes any Subscription that has the specified subscriber.
subscriber | The subscriber to search for and remove |
CS::Threading::ReadWriteMutex MsgHandler::mutex [protected] |
NetBase* MsgHandler::netbase [protected] |
Definition at line 187 of file msghandler.h.
MsgQueue* MsgHandler::queue [protected] |
Definition at line 188 of file msghandler.h.
csHash<Subscription, msgtype> MsgHandler::subscribers [protected] |
Stores the hash of all subscribers and the message type they are subscribed to.
Definition at line 193 of file msghandler.h.