HNetMessageRegistrar
-
class
HNetMessageRegistrar The
HNetMessageRegistrarclass maps messages from HNetClients or .snap files to MVO calls.Subclassed HNetMessageHandler objects are registered for specific messages.
Methods
-
HNetMessageRegistrar::HNetMessageRegistrar(HBaseView *new_hbaseview, HNetClient *new_hnetclient = 0) Constructs an
HNetMessageRegistrarobject.Parameters
new_hbaseview: This is a pointer to a
HBaseViewobject this registrar instance will deliever messages to.new_hnetclient: Pass a pointer to an HNetClient will you want messages to come from that object or pass null for messages to be generated from .snap files.
-
virtual
HNetMessageRegistrar::~HNetMessageRegistrar() virtual
The
HNetMessageRegistrardestuctor cleans up all HMessageHandler class instance that have been added to it.
-
virtual void
HNetMessageRegistrar::SetHandlers() virtual
This method calls
SetMessageHandler()for all default MVO messages.HNetMessageRegistrarmay be subclassed to set custom message handlers. Custom handlers may also be set by callingSetMessageHandler()for the custom message handlers directly.This function must be called by the user to set the default handlers. If it is not called, no default handlers will be set.
-
virtual void
HNetMessageRegistrar::UnSetHandlers() virtual
This method clears all message handlers that have been set. It is called when the registrar is deleted but may be called at any time to remove handlers.
-
virtual HNetMessageHandler *
HNetMessageRegistrar::SetMessageHandler(HNetMessageHandler *handler, char const *message_type) virtual
This method sets a handler for a specific message. The old handler if one existed is returned to caller.
For example:
SetMessageHandler(0,"H_INSERT_NURBS"); This example removes the handler for message H_INSERT_NURBS.
SetMessageHandler( new HMarkupMessageHandler(hbaseview), "H_INSERT_MARKUP_LAYER_HSF_DATA"); This example sets :cpp:class:`~HMarkupMessageHandler` for message H_INSERT_MARKUP_LAYER_HSF_DATA.
SetMessageHandler( new MyDefaultHandler(hbaseview), 0); This example sets MyDefaultHandler as the handler for all messages without other handlers.
Parameters
handler: A pointer to a subclassed HNetMessageHandler for the specifed message. A value of 0 will unset the handler.
message_type: A character pointer denoting the type of message to be handled. If message_type is 0, then the object is set as the default message handler and any message which doesn’t have a specific handler is dispatched to the default handler.
Returns
A pointer to the handler that was previously registered to handle this message if one existed. If not, then the return value is 0.
-
bool
HNetMessageRegistrar::ReadSnapFile(char const *file_name) A snap file created by a hnet_server may be loaded and “played back” using this method. It can only be used if the HMessageRegistrar was created without a HNetClient.
Parameters
file_name: The name of the snap file to load.Returns
This returns true if the file opened and was processes and false if loading failed because the file counln’t be read or the registrar had a HNetClient.
-
virtual void
HNetMessageRegistrar::ProcessMessage(char const *message, unsigned long message_length) protected virtual
This is used by the snap file loader to send a single message.
Parameters
message: A pointer to the message data.
message_length: The lenght of the message data.
-
static void
HNetMessageRegistrar::net_unset_message_handler_helper(void *handler, char const *message, void *user_data) private static
-
static void
HNetMessageRegistrar::non_net_unset_message_handler_helper(void *handler, char const *message, void *user_data) private static
Variables
-
HBaseView *
HNetMessageRegistrar::hbaseview protected
This is the
HBaseViewfor this registrar.
-
HNetClient *
HNetMessageRegistrar::hnetclient protected
HNetClientThis is the HNetClient for this registrar.
-
struct vhash_s *
HNetMessageRegistrar::message_handler_hash private
struct vhash_s
-
HNetMessageHandler *
HNetMessageRegistrar::default_message_handler private
HNetMessageHandler