Planeshift
ClientMsgHandler Class Reference

Handles messages to be sent out, connects to server and send those. More...

#include <clientmsghandler.h>

Public Member Functions

 ClientMsgHandler ()
 
bool Connect (const char *server, int port)
 This is a conveniance function that basically calls NetBase::Connect. More...
 
 DeclareGenericEventHandler (EventHandler, ClientMsgHandler,"planeshift.clientmsghandler")
 Declare our event handler. More...
 
bool DispatchQueue ()
 This function Publish all messages currently in the inbound message queue. More...
 
int GetNextSequenceNumber (msgtype mtype)
 Get the next sequence number to use for an ordered message. More...
 
bool HandleEvent (iEvent &Event)
 This function implementes the iEventHandler interface and is called whenever a subscribed event occurs. More...
 
bool Initialize (NetBase *nb, iObjectRegistry *object_reg)
 Initializes the Handler. More...
 
void SendMessage (MsgEntry *msg)
 Send outgoing messages, setting the clientnum automatically beforehand. More...
 
virtual ~ClientMsgHandler ()
 
- Public Member Functions inherited from MsgHandler
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. More...
 
bool Flush ()
 Flush the connected output queue. More...
 
csTicks GetPing ()
 
bool Initialize (NetBase *nb, int queuelen=500)
 Initializes the Handler. More...
 
 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. More...
 
void Publish (MsgEntry *msg)
 Distribute message to all subscribers. More...
 
virtual void Subscribe (iNetSubscriber *subscriber, msgtype type, uint32_t flags=0x01)
 Subscribes an iNetSubscriber to a specific message type. More...
 
virtual bool Unsubscribe (iNetSubscriber *subscriber, msgtype type)
 Unsubscribes a subscriber from a specific message type. More...
 
virtual bool UnsubscribeAll (iNetSubscriber *subscriber)
 Searches all message types and deletes any Subscription that has the specified subscriber. More...
 
virtual ~MsgHandler ()
 

Public Attributes

csRef< EventHandler > scfiEventHandler
 

Protected Attributes

iObjectRegistry * object_reg
 
csHash< OrderedMessageChannel * > orderedMessages
 
- Protected Attributes inherited from MsgHandler
CS::Threading::ReadWriteMutex mutex
 Protects subscribers. More...
 
NetBasenetbase
 
MsgQueuequeue
 
csHash< Subscription, msgtypesubscribers
 Stores the hash of all subscribers and the message type they are subscribed to. More...
 

Additional Inherited Members

- Public Types inherited from MsgHandler
typedef NetBase::broadcasttype broadcasttype
 import the broadcasttype More...
 

Detailed Description

Handles messages to be sent out, connects to server and send those.

Definition at line 38 of file clientmsghandler.h.

Constructor & Destructor Documentation

ClientMsgHandler::ClientMsgHandler ( )
virtual ClientMsgHandler::~ClientMsgHandler ( )
virtual

Member Function Documentation

bool ClientMsgHandler::Connect ( const char *  server,
int  port 
)

This is a conveniance function that basically calls NetBase::Connect.

ClientMsgHandler::DeclareGenericEventHandler ( EventHandler  ,
ClientMsgHandler  ,
"planeshift.clientmsghandler"   
)

Declare our event handler.

bool ClientMsgHandler::DispatchQueue ( )

This function Publish all messages currently in the inbound message queue.

int ClientMsgHandler::GetNextSequenceNumber ( msgtype  mtype)

Get the next sequence number to use for an ordered message.

bool ClientMsgHandler::HandleEvent ( iEvent &  Event)

This function implementes the iEventHandler interface and is called whenever a subscribed event occurs.

We use this to trap idle events and process the incoming queue during those times instead of running a separate thread.

bool ClientMsgHandler::Initialize ( NetBase nb,
iObjectRegistry *  object_reg 
)

Initializes the Handler.

void ClientMsgHandler::SendMessage ( MsgEntry msg)
inlinevirtual

Send outgoing messages, setting the clientnum automatically beforehand.

Reimplemented from MsgHandler.

Definition at line 56 of file clientmsghandler.h.

Member Data Documentation

iObjectRegistry* ClientMsgHandler::object_reg
protected

Definition at line 80 of file clientmsghandler.h.

csHash<OrderedMessageChannel*> ClientMsgHandler::orderedMessages
protected

Definition at line 81 of file clientmsghandler.h.

csRef<EventHandler> ClientMsgHandler::scfiEventHandler

Definition at line 77 of file clientmsghandler.h.


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