RPCResult

template<class _T>
class kanzi::connect::RPCResult

Wrapper for concrete RPC results.. provides limited and more convinient access.

Public Functions

inline RPCResult()

Default c++ constructor.

inline RPCTypes::CallbackFunctionSubscriptionToken addCallback(typename RPCResultImpl<_T>::CallbackFunctionType callback)

Add callback.

Return

subscription handle.

Parameters
  • callback: to be called when ready.

inline RPCTypes::CallbackFunctionSubscriptionToken addCallbackEx(RPCResultObserver<_T> *callback)

Add callback.

Return

subscription handle.

Parameters
  • callback: to be called when ready.

inline bool complete(_T value, int32_t rpcresult = GenericRPCReplyMessage::RPC_RESULT_OK)

Completes an object.

Normally this is not meant to be used by RPC users but completion is done internally by the Kanzi Connect framework.

Return

If completion is done, true. If completion has already been completed, false.

Parameters
  • rpcresult: The RPC level completion value.

inline int32_t getRPCCallResult() const

Retrieve low level rpc status of the method call.

Return

RPC status.

inline _T getValue() const

Return the value of a call.

Will block calling thread if remote-call is not complete yet.

Return

value

inline void invalidate()

Releases all the referenced resources. After calling this it is not safe to access any other methods except the valid().

inline bool isComplete() const

Check has call completed.

Return

true if completed.

inline bool isLinkBroken() const

Has the link been broken and caused the RPC call to terminate.

Return

true if link was broken and caused the operation to fail because if that.

inline bool isTimedOut() const

Has the request been timed out.

Return

true if timed out.

inline void removeCallback(RPCTypes::CallbackFunctionSubscriptionToken token)

Remove a callback.

Parameters
  • token: subscription to remove.

inline void setTimeout(int ms)

Sets the timeout after which the operation is completed locally with timed-out status.

Note

the timeout is not millisecond accurate but its quaranteed that the timeout is not signaled before specified amount of milliseconds has elapsed. Timeouts are in practise evaluated when ever information is received from the kanzi connect server.

Parameters
  • ms: Timeout in milliseconds.

inline bool valid() const

is object OK

Return

true if ok.

inline bool waitComplete(int32_t ms) const

Wait until complete.

Return

true if call became ready. false if still pending.

Parameters
  • ms: maximum amount of milliseconds to wait.

Public Static Functions

static inline RPCResult<_T> create(RPCTypes::CommHandle handle)

Factory function to create a pending RPC Result object with handle provided.

Parameters
  • handle: the handle for the object.