VLink  2.0.0
A high-performance communication middleware
vlink::ClientImpl Class Referenceabstract

Connection-aware base class for method-model client implementations. More...

#include <client_impl.h>

Inheritance diagram for vlink::ClientImpl:
Collaboration diagram for vlink::ClientImpl:

Public Member Functions

 ~ClientImpl () override
 Releases the helper state held by the base class. More...
 
void interrupt () override
 Wakes blocked waiters and forwards the interrupt to NodeImpl. More...
 
virtual void detect_connected (ConnectCallback &&callback)
 Registers callback to fire whenever the server presence changes. More...
 
virtual bool wait_for_connected (std::chrono::milliseconds timeout)
 Blocks until a server becomes reachable or timeout elapses. More...
 
virtual bool is_connected () const =0
 Reports whether the transport currently holds a path to a server. More...
 
virtual bool call (const Bytes &req_data, MsgCallback &&callback, std::chrono::milliseconds timeout)=0
 Performs a synchronous round-trip with the remote server. More...
 
void update_connected ()
 Notifies the base class that the underlying connection state may have changed. More...
 

Public Attributes

bool is_resp_type {false}
 true when the public Client expects a response payload. More...
 

Protected Member Functions

 ClientImpl ()
 Stamps the node as kClient and prepares the helper state. More...
 

Additional Inherited Members

Detailed Description

Connection-aware base class for method-model client implementations.

Owns the helper condition variable used by wait_for_connected() and the cached ConnectCallback delivered via detect_connected(). Backends are expected to push presence updates by calling update_connected() whenever the discovery layer reports a server appear / disappear event.

Constructor & Destructor Documentation

◆ ~ClientImpl()

vlink::ClientImpl::~ClientImpl ( )
override

Releases the helper state held by the base class.

◆ ClientImpl()

vlink::ClientImpl::ClientImpl ( )
protected

Stamps the node as kClient and prepares the helper state.

Member Function Documentation

◆ call()

virtual bool vlink::ClientImpl::call ( const Bytes req_data,
MsgCallback &&  callback,
std::chrono::milliseconds  timeout 
)
pure virtual

Performs a synchronous round-trip with the remote server.

Pure virtual; subclasses send req_data, wait for the matching response (typically through AckManager) and invoke callback with the received bytes once a frame arrives.

Parameters
req_dataSerialised request payload.
callbackCallable void(const Bytes&) receiving the response bytes.
timeoutMaximum wait duration; negative for unlimited.
Returns
true on success; false on timeout, interruption or transport error.

◆ detect_connected()

virtual void vlink::ClientImpl::detect_connected ( ConnectCallback &&  callback)
virtual

Registers callback to fire whenever the server presence changes.

If the connection is already established at registration time, callback is invoked with true before this method returns. Subsequent transitions are forwarded by update_connected().

Parameters
callbackCallable void(bool) to be notified on connect / disconnect.

◆ interrupt()

void vlink::ClientImpl::interrupt ( )
overridevirtual

Wakes blocked waiters and forwards the interrupt to NodeImpl.

Marks the node interrupted, notifies the helper condition variable so any wait_for_connected() call returns false promptly, and delegates the rest of the shutdown handshake to NodeImpl::interrupt(). Transport subclasses commonly override this to also cancel pending AckManager requests.

Reimplemented from vlink::NodeImpl.

◆ is_connected()

virtual bool vlink::ClientImpl::is_connected ( ) const
pure virtual

Reports whether the transport currently holds a path to a server.

Pure virtual; subclasses query their underlying discovery handle. Called by both wait_for_connected() and update_connected() to compute state transitions.

Returns
true when a server is reachable; false otherwise.

◆ update_connected()

void vlink::ClientImpl::update_connected ( )

Notifies the base class that the underlying connection state may have changed.

Compares is_connected() against the helper cache; when the value flips the condition variable is signalled and any registered ConnectCallback is delivered. Intended to run on the transport's discovery / listener thread, not on the application thread.

◆ wait_for_connected()

virtual bool vlink::ClientImpl::wait_for_connected ( std::chrono::milliseconds  timeout)
virtual

Blocks until a server becomes reachable or timeout elapses.

Returns immediately when is_connected() already reports true. Otherwise sleeps on the helper condition variable that is poked by update_connected() and by interrupt(). A negative timeout, such as Timeout::kInfinite, disables the deadline.

Parameters
timeoutMaximum sleep duration.
Returns
true when the server appeared in time; false on timeout or interruption.

Member Data Documentation

◆ is_resp_type

bool vlink::ClientImpl::is_resp_type {false}

true when the public Client expects a response payload.


The documentation for this class was generated from the following file: