VLink  2.0.0
A high-performance communication middleware
proxy_server.h 文件参考

Daemon-side half of the VLink proxy subsystem – one server per process. 更多...

#include <cstdint>
#include <memory>
#include <string>
#include <vector>
#include "../base/message_loop.h"
proxy_server.h 的引用(Include)关系图:

浏览源代码.

class  vlink::ProxyServer
 In-process VLink proxy daemon backed by a MessageLoop. 更多...
 
struct  vlink::ProxyServer::Config
 Construction-time configuration aggregate for ProxyServer. 更多...
 

命名空间

 

宏定义

#define VLINK_PROXY_SERVER_EXPORT   __attribute__((visibility("default")))
 

详细描述

Daemon-side half of the VLink proxy subsystem – one server per process.

ProxyServer is the in-process daemon that mediates between the VLink core (publishers, subscribers, setters, getters on the local DDS domain) and one or more ProxyAPI clients. It derives from MessageLoop, so once async_run() is called all scheduled work, timers, and asynchronous relays run inside the inherited loop's worker thread.

Behaviourally the server is responsible for the following duties:

  1. Hosts an internal DiscoveryViewer that enumerates every active publisher and subscriber on the DDS domain.
  2. Accepts Control messages from ProxyAPI clients over a security-authenticated DDS channel and dispatches them to the discovery layer.
  3. Broadcasts a 1-second Time heartbeat carrying CPU/memory usage, the VLink version string, hostname, machine ID, and wall-clock plus boot-time.
  4. Publishes per-topic statistics – freq, rate, loss, latency – once per second through a security-authenticated InfoList channel.
  5. Relays raw payload bytes from observed publishers and setters back to connected ProxyAPI listeners. In direct mode the data pubs/subs are created by the API side and the server stays exclusively on the control/discovery path; setter endpoints are observed with getter semantics so field last-value delivery is preserved.
  6. Optionally launches an embedded Iceoryx RouDi daemon when Config::use_iox is true.
  7. Loads RunablePluginInterface shared-library plugins listed in Config::runnable_list at construction and drives their lifecycle from the inherited MessageLoop callbacks.
Singleton Constraint
Only one ProxyServer may exist per operating-system process. A second construction logs a fatal message and throws before any DDS channels are wired up; running multiple servers in the same process is not supported and not safe.
Architecture Diagram
+-----------------------+ +---------------------+
| ProxyAPI (Controller) | | ProxyAPI (Listener) |
+-----------+-----------+ +----------+----------+
| |
| HandshakeCli ---[DDS secure]---> HandshakeSrv (issues token)
|<--------------- token --------------|
| ControlPub ---[DDS secure]---> ControlSub (token-stamped)
v v
+-------------------------------------------------------------+
| ProxyServer (this) |
| +-------------------+ +-------------------------------+ |
| | DiscoveryViewer | | Heartbeat / Info / Data path | |
| +-------------------+ +-------------------------------+ |
| ^ | | |
+-------|--------------------------|----------|---------------+
| v v
[VLink core nodes] TimePub / InfoPub ---[DDS secure]--->
DataPub ---[DDS / SHM]--->
Authentication Token
At construction the server generates a 128-bit hex session token via vlink::Uuid::random_hex() and exposes it through get_token(). The token is a process-lifetime protocol nonce, not a long-term cryptographic key. Clients fetch it by invoking the handshake RPC over the security-authenticated DDS channel; subsequent Control messages without a matching token are dropped server-side. Restarting the server invalidates every previously-issued token. Clients re-handshake after a same-identity token mismatch heartbeat, an identity-mismatch heartbeat that also carries a different token, or a local reset, before they will accept further heartbeats or publish new controls.
Runnable Plugin Lifecycle
Plugins named in Config::runnable_list are loaded inside the constructor. When the inherited MessageLoop starts (on_begin), each plugin's on_init() and async_run() are invoked in list order. On loop stop (on_end) each plugin's on_deinit(), quit(), and wait_for_quit() are invoked in the same order.
Environment Variables
Variable Meaning
VLINK_INTRA_BIND When set to any value, also subscribe to intra:// topics.
Example
cfg.dds_impl = "dds";
cfg.domain_id = 0;
cfg.reliable = false;
cfg.async = true;
cfg.use_iox = false;
vlink::ProxyServer server(cfg);
server.async_run(); // start the inherited MessageLoop in a background thread
// ... application runs ...
server.quit(true);
server.wait_for_quit();
注解
  • Construction must happen on the main thread, before any ProxyAPI client connects on the same domain.
  • Destruction stops every timer, joins the DiscoveryViewer, and releases each DDS handle in a deterministic order so no dangling callback can fire after teardown.

宏定义说明

◆ VLINK_PROXY_SERVER_EXPORT

#define VLINK_PROXY_SERVER_EXPORT   __attribute__((visibility("default")))