RPCResultImpl

template<class _T>
class kanzi::connect::RPCResultImpl : public kanzi::connect::RPCResultBase<_T>, public enable_shared_from_this<RPCResultImpl<_T>>

Base template class for non-void RPC results.

Public Types

typedef function<void(RPCResult<_T>&)> CallbackFunctionType

Callback function type.

Public Functions

inline RPCResultImpl(RPCTypes::CommHandle handle)

C++ constructs - initializes the object.

Parameters
  • handle: the handle for the operation.

inline RPCTypes::CallbackFunctionSubscriptionToken addCallback(CallbackFunctionType callback)

Adds a callback to listen method response.

Invoked when response is received.

Return

token that can be used to remove callback if needed.

Parameters
  • callback: pointer to function to call.

bool completeIfTimedOut(const chrono::steady_clock::time_point&)

Completes the operation if it has been timed out.

Return

true if timed out

void completeLinkBroken()

Completes the operation with link broken status.

inline void doComplete(_T value, int32_t rpcresult = GenericRPCReplyMessage::RPC_RESULT_OK)

Completes the RPC result promise.

Parameters
  • value: complete value

inline _T getValue()

Gets the value.

Note

can be called only once.

Return

the value of the future.

inline void removeCallback(RPCTypes::CallbackFunctionSubscriptionToken token)

Removes callback from the callback array.

Parameters
  • token: callback to remove, token returned by addCallback function.