RadarFX API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
2 - Design Concepts

Table of Contents

This section lists several of the design concepts and patterns that are used within the RadarFX SDK.

2.1 Connector

The DtRadarFxConnector class is the primary class that a client application needs to create. It is used to communicate with the RadarFX server. The Connector class creates and owns a TCP connection to the server. The Connector maintains this connection in a separate thread and will poll the thread for data on its own as well as manage passing messages between the network thread and the main thread. The user does need to periodically call the tick() function of the Connector to all the class to process any received messages through its message handler.

2.2 Messages

Messages are how RadarFX clients communicate with the server. All requests and responses are encapsulated in messages. Messages are able to serialize and deserialize themselves using the byte stream helper class. Messages also have a unique type ID which is a 32-bit integer. Message types are defined in the radarFxShared/rfxMessageTypes.h header.

All messages have an id and a requester name. The requester name is unique and assigned by the connection that is used to send the message to the server. This allows the server to respond to the correct client if the message is a request. The ID is used to track which request is sent by a client in the case that more than one request is submitted before the server is able to respond.

2.3 The MessageFactory

Messages are created by a factory in both the server and the connector when the message is transmitted over the TCP socket. When messages arrive from a TCP socket, the factory is used to create the correct type of message with the correct data fields from the bytes received.

2.4 Delegates

Delegates are C++ classes that wrap a function to callback at a later time. These are used for message handlers that are registered with the message handler. Delegates can wrap global functions, member functions of a class, or static member functions of a class.

2.5 The Message Handler

The DtMessageHandler class maintains a list of delegates that are registered for each type of message. The message handler processes the messages by running each of the registered delegates with the passed in message. The order that delegates are run in is not guaranteed when there is more than one delegate for a given message type. When a message delegate is running, the message that is passed into the client function is only valid while the function is running, once the function goes out of scope, the message will too. Do not keep a pointer to the message for later use, it will not be valid and will cause a crash if the client uses it outside of the delegate.

[<< Introduction to the RadarFX API] [Home] [Top of Page] [The Client API >>]



Copyright © 2024 MAK Technologies, Inc. All Rights Reserved (www.mak.com)