The HNetMessageRegistrar class maps messages from HNetClients or .snap files to MVO calls. More...

#include <HNetMessageRegistrar.h>

Public Member Functions

 HNetMessageRegistrar (HBaseView *new_hbaseview, HNetClient *new_hnetclient=0)
bool ReadSnapFile (const char *file_name)
virtual void SetHandlers ()
virtual HNetMessageHandler * SetMessageHandler (HNetMessageHandler *handler, const char *message_type)
virtual void UnSetHandlers ()
virtual ~HNetMessageRegistrar ()

Protected Member Functions

virtual void ProcessMessage (const char *message, unsigned long message_length)

Protected Attributes

 This is the HBaseView for this registrar.
HNetClient * hnetclient
 This is the HNetClient for this registrar.

Detailed Description

The HNetMessageRegistrar class maps messages from HNetClients or .snap files to MVO calls.

Subclassed HNetMessageHandler objects are registered for specific messages.

Constructor & Destructor Documentation

◆ HNetMessageRegistrar()

HNetMessageRegistrar::HNetMessageRegistrar ( HBaseView new_hbaseview,
HNetClient *  new_hnetclient = 0 

Constructs an HNetMessageRegistrar object.

new_hbaseviewThis is a pointer to a HBaseView object this registrar instance will deliever messages to.
new_hnetclientPass 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.

References hbaseview, and hnetclient.

◆ ~HNetMessageRegistrar()

virtual HNetMessageRegistrar::~HNetMessageRegistrar ( )

The HNetMessageRegistrar destuctor cleans up all HMessageHandler class instance that have been added to it.

References UnSetHandlers().

Member Function Documentation

◆ ProcessMessage()

virtual void HNetMessageRegistrar::ProcessMessage ( const char *  message,
unsigned long  message_length 

This is used by the snap file loader to send a single message.

messageA pointer to the message data.
message_lengthThe lenght of the message data.

References hnetclient.

Referenced by ReadSnapFile().

◆ ReadSnapFile()

bool HNetMessageRegistrar::ReadSnapFile ( const char *  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.

file_nameThe name of the snap file to load.
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.

References hnetclient, and ProcessMessage().

◆ SetHandlers()

virtual void HNetMessageRegistrar::SetHandlers ( )

This method calls SetMessageHandler() for all default MVO messages. HNetMessageRegistrar may be subclassed to set custom message handlers. Custom handlers may also be set by calling SetMessageHandler() 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.

References hbaseview, and SetMessageHandler().

◆ SetMessageHandler()

virtual HNetMessageHandler* HNetMessageRegistrar::SetMessageHandler ( HNetMessageHandler *  handler,
const char *  message_type 

This method sets a handler for a specific message. The old handler if one existed is returned to caller.

handlerA pointer to a subclassed HNetMessageHandler for the specifed message. A value of 0 will unset the handler.
message_typeA 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.
A pointer to the handler that was previously registered to handle this message if one existed. If not, then the return value is 0.

For example:


This example removes the handler for message H_INSERT_NURBS.

SetMessageHandler( new HMarkupMessageHandler(hbaseview), "H_INSERT_MARKUP_LAYER_HSF_DATA");

This example sets 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.

References hnetclient.

Referenced by SetHandlers().

◆ UnSetHandlers()

virtual void HNetMessageRegistrar::UnSetHandlers ( )

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.

References hnetclient.

Referenced by ~HNetMessageRegistrar().

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