VLink  2.0.0
A high-performance communication middleware
vlink::ServerImpl类 参考abstract

Method-model server base shared by every transport implementation. 更多...

#include <server_impl.h>

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

Public 成员函数

 ~ServerImpl () override
 Releases backend resources. 更多...
 
virtual bool listen (ReqRespCallback &&callback)=0
 Registers the request / response handler. 更多...
 
virtual bool has_clients () const
 Reports whether 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 once listen() has been registered successfully. 更多...
 
bool is_resp_type {false}
 true when the server is expected to produce a response. 更多...
 
bool is_sync_type {false}
 true when the reply is delivered inside the request callback. 更多...
 

Protected 成员函数

 ServerImpl ()
 Stamps the node as kServer. 更多...
 

额外继承的成员函数

详细描述

Method-model server base shared by every transport implementation.

Backends override listen() to bind the supplied callback to the transport receive path and, where supported, override has_clients() and reply() to expose client discovery and asynchronous responses respectively.

构造及析构函数说明

◆ ~ServerImpl()

vlink::ServerImpl::~ServerImpl ( )
override

Releases backend resources.

◆ ServerImpl()

vlink::ServerImpl::ServerImpl ( )
protected

Stamps the node as kServer.

成员函数说明

◆ has_clients()

virtual bool vlink::ServerImpl::has_clients ( ) const
virtual

Reports whether at least one client is currently connected.

Default returns false. Backends that expose matched-publication discovery override the method.

返回
true when one or more clients are reachable.

◆ listen()

virtual bool vlink::ServerImpl::listen ( ReqRespCallback &&  callback)
pure virtual

Registers the request / response handler.

Pure virtual. The callback is invoked for every incoming RPC with the request bytes and a unique req_id; the handler writes the response into *resp_data, or receives nullptr in fire-and-forget mode. The owning Server marks is_listened to true once this method succeeds.

参数
callbackCallable void(uint64_t req_id, const Bytes& req_data, Bytes* resp_data).
返回
true on success; false on registration 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) when the response is produced after the request callback returns. The base implementation warns when is_sync is false and always returns false; backends that support deferred replies override the method.

参数
req_idIdentifier supplied to the request callback.
resp_dataSerialised response payload.
is_synctrue when called synchronously inside the request callback.
返回
true on success; false otherwise.

类成员变量说明

◆ is_listened

bool vlink::ServerImpl::is_listened {false}

true once listen() has been registered successfully.

◆ is_resp_type

bool vlink::ServerImpl::is_resp_type {false}

true when the server is expected to produce a response.

◆ is_sync_type

bool vlink::ServerImpl::is_sync_type {false}

true when the reply is delivered inside the request callback.


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