AbstractInterfaceClient

class kanzi::connect::AbstractInterfaceClient

An abstract client-side network interface class for services in Kanzi Connect network.

Subclassed by InterfaceClient< InterfaceObserver, ExternalClientSession >, InterfaceClient< ObserverClass, SessionClass >

Public Types

typedef function<void(bool)> ServiceReachableCallback

Callback to inform whether service at server is available or not.

Public Functions

AbstractInterfaceClient(RPCCallStore &callStore)

Constructor.

virtual ~AbstractInterfaceClient()

Destructor.

AbstractSessionSharedPtr acquireAbstractSession(MessageDispatcher *dispatcher)

Acquires a session for this interface.

Return

Session that was created.

Parameters
  • dispatcher: Message dispatcher that is used to deliver network messages.

virtual string getIdentifier() const = 0

Returns the type id of the interface.

This is used to identify the service in the network.

Return

Type of the interface, as a string.

shared_ptr<p2p::RoutingRules> getRoutingRules()

Retrieve routing rules for this particular client.

Return

routing defintion.

AbstractSessionSharedPtr getSession(int sessionId)

Returns session by id.

Return

Session that matches given id, or 0 if there was no such session.

Parameters
  • sessionId: Id of the session.

bool isSessionRunning(AbstractSessionSharedPtr session) const

Check if the given session is running or not.

Return

True if the session is running

Parameters
  • session: The session to check

void notifyServiceReachable(bool reachable)

Invoked to notify clients whether specific service is reachable or not.

virtual void receive(const MessagePackage &message)

Pass a message package to this interface, resolves proper session and makes it receive the package.

Parameters
  • message: Message that was sent.

virtual void registerRemoteInterface(MessageTranslator *translator)

Registers this interface to given message translator.

Parameters
  • translator: Translator to receive the interface definition.

void releaseAbstractSession(AbstractSessionSharedPtr session)

Releases given session from this interface.

Parameters
  • session: Session to release.

bool serviceReachable() const

Is service currently known to be reachable.

Return

true if service is reachable.

inline void setClient(ClientSharedPtr client)

Stores the client this interface is bound to.

void setServiceReachableCallback(ServiceReachableCallback callback)

Registers service reachable callback.

Parameters
  • callback: the callback to configure.

void setSessionRunning(AbstractSessionSharedPtr session)

Set the given session to running state.

Parameters
  • session: The session to set

void setSessionStopped(AbstractSessionSharedPtr session)

Set the given session to stopped state.

Parameters
  • session: The session to set

void stopAllSessions()

Ends all sessions since maybe the service itself has disappeared.

void terminateAllSessions()

Terminates all ongoing sessions.