RDMnet
0.3.0
Implementation of ANSI E1.33 (RDMnet)
|
View other versions:
|
The RDMnet broker API exposes a C++11 interface for creating instances of RDMnet broker functionality.
NOTE: Typically, RDMnet broker functionality should have its own dedicated service, and not be included directly in applications. This API is useful for building an RDMnet broker service, or for applications where background services are not available, such as mobile platforms.
The RDMnet library must be globally initialized before using the RDMnet broker API. See Global Initialization and Destruction.
To create a broker instance, instantiate an rdmnet::Broker and call its Startup() function. A broker can operate on a single RDMnet scope at a time; the initial scope, and other configuration parameters the broker uses at runtime, are provided via the rdmnet::Broker::Settings struct.
The RDMnet broker API is an asynchronous, callback-oriented API. Part of the initial configuration for a broker instance is an abstract interface for the library to use as callbacks. Callbacks are dispatched from a background thread.
Once running, the broker will spawn a number of worker threads and operate independently with no further action needed. The full breakdown of threads used is described in the rdmnet::Broker class documentation.
The broker should be shut down gracefully before program termination using the Shutdown() function. This function will send graceful disconnect messages to all connected clients, close all network sockets and connections, deallocate resources and join all threads.
The broker's scope can be changed at runtime using the ChangeScope() function.
When the scope changes, the broker will disconnect all currently connected clients using the disconnect reason code given in the disconnect_reason parameter. It will then restart broker services and re-register for discovery using the new scope.
Brokers can log messages using the etcpal::Logger class. To capture logs from the broker, set up an etcpal::Logger instance per its documentation, and pass it to the broker instance on startup:
The broker logs messages at appropriate syslog-style severity levels; for example, if you set the logger's log mask to ETCPAL*LOG_UPTO(ETCPAL_LOG_DEBUG), the broker will log _lots* of messages (including a message logged for every message the broker routes). If you set it to ETCPAL_LOG_UPTO(ETCPAL_LOG_ERR), the logging will be much more sparse and only represent error conditions.
The broker can pass notifications of certain events back to the application for handling. Currently, these notifications are all informational; broker instances operate the same way regardless of how they are handled.
If Broker::Settings::allow_rdm_scope_change was set to true at the initialization of a broker instance, the broker will accept RDM commands which change its scope. When this happens, it will also deliver a scope changed notification to the notification handler.