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 | |
HBaseView * | hbaseview |
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()
|
inline |
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.
References hbaseview, and hnetclient.
◆ ~HNetMessageRegistrar()
|
inlinevirtual |
The HNetMessageRegistrar destuctor cleans up all HMessageHandler class instance that have been added to it.
References UnSetHandlers().
Member Function Documentation
◆ ProcessMessage()
|
inlineprotectedvirtual |
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.
References hnetclient.
Referenced by ReadSnapFile().
◆ ReadSnapFile()
|
inline |
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.
References hnetclient, and ProcessMessage().
◆ SetHandlers()
|
inlinevirtual |
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()
|
inlinevirtual |
This method sets a handler for a specific message. The old handler if one existed is returned to caller.
- 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.
For example:
SetMessageHandler(0,"H_INSERT_NURBS");
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.
References hnetclient.
Referenced by SetHandlers().
◆ UnSetHandlers()
|
inlinevirtual |
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: