HNetMessageRegistrar

Functions

HNetMessageRegistrar

~HNetMessageRegistrar

void

SetHandlers

void

UnSetHandlers

HNetMessageHandler *

SetMessageHandler

bool

ReadSnapFile

Detailed Description

class HNetMessageRegistrar

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

Subclassed HNetMessageHandler objects are registered for specific messages.

Public Functions

inline HNetMessageRegistrar(HBaseView *new_hbaseview, HNetClient *new_hnetclient = 0)

Constructs an HNetMessageRegistrar object.

Parameters
  • new_hbaseview – This is a pointer to a HBaseView object 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.

inline virtual ~HNetMessageRegistrar()

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

inline virtual void 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.

inline virtual void 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.

inline virtual HNetMessageHandler *SetMessageHandler(HNetMessageHandler *handler, char const *message_type)

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

For example:

This example removes the handler for message H_INSERT_NURBS.

This example sets HMarkupMessageHandler for message H_INSERT_MARKUP_LAYER_HSF_DATA.

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.

inline bool 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.