|
VLink 2.0.0
A high-performance communication middleware
|
Transport-agnostic base for server (RPC responder) node implementations. More...
#include <server_impl.h>
Public Member Functions | |
| ~ServerImpl () override | |
| Destructor. | |
| virtual bool | listen (ReqRespCallback &&callback)=0 |
| Registers the request handler callback. | |
| virtual bool | has_clients () const |
Returns true when at least one client is currently connected. | |
| virtual bool | reply (uint64_t req_id, const Bytes &resp_data, bool is_sync) |
| Sends a response for a previously received request. | |
| Public Member Functions inherited from vlink::NodeImpl | |
| virtual void | init ()=0 |
| Initialises the underlying transport channel. | |
| virtual void | deinit ()=0 |
| Tears down the underlying transport channel. | |
| virtual bool | suspend () |
| Temporarily suspends message delivery without tearing down the channel. | |
| virtual bool | resume () |
Resumes message delivery after a suspend() call. | |
| virtual bool | is_suspend () const |
Returns true when the node is currently suspended. | |
| virtual void | interrupt () |
| Signals any blocking operations to unblock and return immediately. | |
| virtual bool | is_support_loan () const |
Returns true if the transport supports zero-copy loaning. | |
| virtual Bytes | loan (int64_t size) |
Borrows a write buffer of size bytes from the transport. | |
| virtual bool | return_loan (const Bytes &bytes) |
| Returns a previously loaned buffer to the transport. | |
| virtual void | set_manual_unloan (bool manual_unloan) |
| Configures manual unloan mode for zero-copy transports. | |
| virtual const struct Conf * | get_conf () const |
Returns a pointer to the associated Conf configuration object. | |
| virtual const AbstractNode * | get_abstract_node () const |
Returns a pointer to the AbstractNode peer (if any). | |
| virtual Status::BasePtr | get_status (Status::Type type) const |
| Retrieves a transport-specific status object. | |
| virtual bool | check_version (const Version &version) |
Checks whether version matches the runtime VLink library version. | |
| virtual bool | attach (class MessageLoop *message_loop) |
Attaches the node to a MessageLoop for callback dispatch. | |
| virtual bool | detach () |
Detaches the node from its MessageLoop. | |
| class MessageLoop * | get_message_loop () const |
Returns the MessageLoop this node is attached to. | |
| template<typename T> | |
| const T * | get_target_conf () const |
Returns a typed pointer to the conf by downcasting to T. | |
| void | register_status_handler (StatusCallback &&callback) |
| Registers a callback for DDS status events. | |
| bool | has_register_status () const |
Returns true if a status handler has been registered. | |
| void | call_status (Status::BasePtr ptr) |
| Dispatches a status event to the registered status handler. | |
| void | set_property (const std::string &prop, const std::string &value) |
| Sets a named transport property on this node. | |
| std::string | get_property (const std::string &prop) const |
| Retrieves a named transport property. | |
| Conf::PropertiesMap | get_all_properties () const |
| Returns a snapshot of all properties set on this node. | |
| void | set_discovery_enabled (bool enable) |
| Enables or disables discovery reporting for this node. | |
| bool | get_discovery_enabled () const |
Returns true if discovery reporting is enabled for this node. | |
| void | set_record_path (const std::string &path) |
| Sets the file path for per-node message recording. | |
| void | set_ssl_options (const SslOptions &options) |
| Merges SSL/TLS options into the node property map. | |
| void | try_record (ActionType action_type, const Bytes &data) |
| Records a message to the global and/or per-node bag writers. | |
| void | reset_interrupted () |
Clears the interrupted flag set by interrupt(). | |
| bool | is_interrupted () const |
Returns true if interrupt() has been called and not yet reset. | |
| void | init_ext () |
Registers the node with the global DiscoveryReporter. | |
| void | deinit_ext () |
Deregisters the node from the global DiscoveryReporter. | |
Public Attributes | |
| bool | is_listened {false} |
true after listen() has been successfully called. | |
| bool | is_resp_type {false} |
true when the server sends a response (vs fire-and-forget). | |
| bool | is_sync_type {false} |
true when the reply is sent synchronously inside the callback. | |
| Public Attributes inherited from vlink::NodeImpl | |
| std::atomic_bool | has_suspend {false} |
| Atomic suspend state flag (currently unused by default impls). | |
| std::string | url |
Full URL string of this node (e.g. "dds://my/topic"). | |
| std::string | ser_type |
Serialisation type string (e.g. "demo.proto.PointCloud"). | |
| ImplType | impl_type {kUnknownImplType} |
| Role of this implementation node. | |
| SchemaType | schema_type {SchemaType::kUnknown} |
| Coarse schema family reported to discovery and bag/proxy paths. | |
| TransportType | transport_type {TransportType::kUnknown} |
| Transport backend of this implementation node. | |
| bool | is_cdr_type {false} |
true when using DDS native CDR serialisation. | |
| bool | is_security_type {false} |
true when security-authenticated transport is enabled. | |
| bool | is_discovery_enabled {true} |
| Whether this node is reported to the discovery layer. | |
| std::unique_ptr< class CpuProfiler > | profiler |
| Optional per-node CPU profiler (only when global profiling is on). | |
Protected Member Functions | |
| ServerImpl () | |
Protected constructor; initialises the server with kServer role. | |
| Protected Member Functions inherited from vlink::NodeImpl | |
| NodeImpl (ImplType type) | |
| virtual | ~NodeImpl () |
Additional Inherited Members | |
| Public Types inherited from vlink::NodeImpl | |
| using | ConnectCallback = std::function<void(bool)> |
| Callback invoked when the peer connection state changes. | |
| using | StatusCallback = std::function<void(const Status::BasePtr& ptr)> |
| Callback invoked on DDS status events (e.g. deadline missed). | |
| using | SyncCallback = std::function<void()> |
Callback invoked when a SetterImpl sync completes. | |
| using | ReqRespCallback = std::function<void(uint64_t, const Bytes&, Bytes*)> |
Callback for ServerImpl request/response processing. | |
| using | MsgCallback = std::function<void(const Bytes&)> |
Callback delivering a raw serialised message to a SubscriberImpl or GetterImpl. | |
| using | IntraMsgCallback = std::function<void(const IntraData&)> |
Callback delivering an in-process IntraData message. | |
| Static Public Member Functions inherited from vlink::NodeImpl | |
| static void | global_init () |
| Initialises process-wide VLink singletons. | |
Transport-agnostic base for server (RPC responder) node implementations.
Concrete backends override listen(ReqRespCallback&&) to register the request handler, and optionally override has_clients() and reply() for client discovery and asynchronous response support respectively.
|
override |
Destructor.
|
protected |
Protected constructor; initialises the server with kServer role.
|
nodiscardvirtual |
Returns true when at least one client is currently connected.
The default implementation returns false. Transports that support client discovery (e.g. DDS matched publications) override this method.
true if one or more clients are connected; false otherwise.
|
pure virtual |
Registers the request handler callback.
Must be implemented by each concrete transport backend. The callback is invoked for every incoming RPC request with the request bytes and a unique identifier. After registration is_listened is set to true by the Server<Req,Resp> layer.
| callback | Callable void(uint64_t req_id, const Bytes& req_data, Bytes* resp_data) invoked for each incoming request. The handler writes its response into *resp_data; nullptr in fire-and-forget mode. |
true if registration succeeded; false on error.
|
virtual |
Sends a response for a previously received request.
Used in asynchronous server mode (is_sync_type = false) to deliver a response after the request callback has returned. req_id must match the identifier provided to the request callback; resp_data contains the serialised response payload.
The default implementation logs a warning when is_sync is false and always returns false. Transports that support asynchronous replies override this method.
| req_id | Unique identifier of the request to respond to. |
| resp_data | Serialised response payload. |
| is_sync | true if called synchronously inside the request callback; false for deferred (post-callback) replies. |
true if the response was queued or sent; false on error. | bool vlink::ServerImpl::is_listened {false} |
true after listen() has been successfully called.
| bool vlink::ServerImpl::is_resp_type {false} |
true when the server sends a response (vs fire-and-forget).
| bool vlink::ServerImpl::is_sync_type {false} |
true when the reply is sent synchronously inside the callback.