VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::ServerImpl类 参考abstract

Transport-agnostic base for server (RPC responder) node implementations. 更多...

#include <server_impl.h>

类 vlink::ServerImpl 继承关系图:
vlink::ServerImpl 的协作图:

Public 成员函数

 ~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 属性

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.

Protected 成员函数

 ServerImpl ()
 Protected constructor; initialises the server with kServer role.

额外继承的成员函数

详细描述

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.

构造及析构函数说明

◆ ~ServerImpl()

vlink::ServerImpl::~ServerImpl ( )
override

Destructor.

◆ ServerImpl()

vlink::ServerImpl::ServerImpl ( )
protected

Protected constructor; initialises the server with kServer role.

函数调用图:
这是这个函数的调用关系图:

成员函数说明

◆ has_clients()

virtual bool vlink::ServerImpl::has_clients ( ) const
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.

◆ listen()

virtual bool vlink::ServerImpl::listen ( ReqRespCallback && callback)
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.

参数
callbackCallable 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.

◆ reply()

virtual bool vlink::ServerImpl::reply ( uint64_t req_id,
const Bytes & resp_data,
bool is_sync )
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_idUnique identifier of the request to respond to.
resp_dataSerialised response payload.
is_synctrue if called synchronously inside the request callback; false for deferred (post-callback) replies.
返回
true if the response was queued or sent; false on error.

类成员变量说明

◆ is_listened

bool vlink::ServerImpl::is_listened {false}

true after listen() has been successfully called.

◆ is_resp_type

bool vlink::ServerImpl::is_resp_type {false}

true when the server sends a response (vs fire-and-forget).

◆ is_sync_type

bool vlink::ServerImpl::is_sync_type {false}

true when the reply is sent synchronously inside the callback.


该类的文档由以下文件生成: