An abstract client-side network interface class for services in Kanzi Connect network. More...
#include <abstract_interface_client.hpp>
Public Types | |
typedef function< void(bool)> | ServiceReachableCallback |
Callback to inform whether service at server is available or not. | |
Public Member Functions | |
AbstractInterfaceClient (RPCCallStore &callStore) | |
Constructor. | |
AbstractSessionSharedPtr | acquireAbstractSession (MessageDispatcher *dispatcher) |
Acquires a session for this interface. | |
virtual string | getIdentifier () const =0 |
Returns the type id of the interface. | |
shared_ptr< p2p::RoutingRules > | getRoutingRules () |
Retrieve routing rules for this particular client. | |
AbstractSessionSharedPtr | getSession (int sessionId) |
Returns session by id. | |
bool | isSessionRunning (AbstractSessionSharedPtr session) const |
Check if the given session is running or not. | |
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. | |
virtual void | registerRemoteInterface (MessageTranslator *translator) |
Registers this interface to given message translator. | |
void | releaseAbstractSession (AbstractSessionSharedPtr session) |
Releases given session from this interface. | |
bool | serviceReachable () const |
Is service currently known to be reachable. | |
void | setClient (ClientSharedPtr client) |
Stores the client this interface is bound to. | |
void | setServiceReachableCallback (ServiceReachableCallback callback) |
Registers service reachable callback. | |
void | setSessionRunning (AbstractSessionSharedPtr session) |
Set the given session to running state. | |
void | setSessionStopped (AbstractSessionSharedPtr session) |
Set the given session to stopped state. | |
void | stopAllSessions () |
Ends all sessions since maybe the service itself has disappeared. | |
void | terminateAllSessions () |
Terminates all ongoing sessions. | |
virtual | ~AbstractInterfaceClient () |
Destructor. | |
Protected Member Functions | |
virtual AbstractSessionSharedPtr | onAcquireSession (int sessionId, MessageDispatcher *dispatcher)=0 |
Function that allows derived classes to create their type-specific session instance. | |
virtual void | onReleaseSession (AbstractSessionSharedPtr session) |
Function that allows derived classes to destroy their type-specific session instance. | |
Protected Attributes | |
RPCCallStore & | m_callStore |
An abstract client-side network interface class for services in Kanzi Connect network.
typedef function<void(bool)> kanzi::connect::AbstractInterfaceClient::ServiceReachableCallback |
Callback to inform whether service at server is available or not.
kanzi::connect::AbstractInterfaceClient::AbstractInterfaceClient | ( | RPCCallStore & | callStore | ) |
Constructor.
|
virtual |
Destructor.
AbstractSessionSharedPtr kanzi::connect::AbstractInterfaceClient::acquireAbstractSession | ( | MessageDispatcher * | dispatcher | ) |
Acquires a session for this interface.
dispatcher | Message dispatcher that is used to deliver network messages. |
|
pure virtual |
Returns the type id of the interface.
This is used to identify the service in the network.
Implemented in kanzi::connect::InterfaceClient< ObserverClass, SessionClass >, and kanzi::connect::InterfaceClient< InterfaceObserver, ExternalClientSession >.
shared_ptr< p2p::RoutingRules > kanzi::connect::AbstractInterfaceClient::getRoutingRules | ( | ) |
Retrieve routing rules for this particular client.
AbstractSessionSharedPtr kanzi::connect::AbstractInterfaceClient::getSession | ( | int | sessionId | ) |
Returns session by id.
sessionId | Id of the session. |
bool kanzi::connect::AbstractInterfaceClient::isSessionRunning | ( | AbstractSessionSharedPtr | session | ) | const |
Check if the given session is running or not.
session | The session to check |
void kanzi::connect::AbstractInterfaceClient::notifyServiceReachable | ( | bool | reachable | ) |
Invoked to notify clients whether specific service is reachable or not.
|
protectedpure virtual |
Function that allows derived classes to create their type-specific session instance.
sessionId | Session Id of the connected client, needs to be unique for this client. |
dispatcher | Message dispatcher that is used to deliver network messages. |
Implemented in kanzi::connect::InterfaceClient< ObserverClass, SessionClass >, and kanzi::connect::InterfaceClient< InterfaceObserver, ExternalClientSession >.
|
inlineprotectedvirtual |
Function that allows derived classes to destroy their type-specific session instance.
session | Session to release. |
Reimplemented in kanzi::connect::ExternalClientInterface.
|
virtual |
Pass a message package to this interface, resolves proper session and makes it receive the package.
message | Message that was sent. |
Reimplemented in kanzi::connect::InterfaceClient< ObserverClass, SessionClass >, and kanzi::connect::InterfaceClient< InterfaceObserver, ExternalClientSession >.
|
virtual |
Registers this interface to given message translator.
translator | Translator to receive the interface definition. |
void kanzi::connect::AbstractInterfaceClient::releaseAbstractSession | ( | AbstractSessionSharedPtr | session | ) |
Releases given session from this interface.
session | Session to release. |
bool kanzi::connect::AbstractInterfaceClient::serviceReachable | ( | ) | const |
Is service currently known to be reachable.
|
inline |
Stores the client this interface is bound to.
void kanzi::connect::AbstractInterfaceClient::setServiceReachableCallback | ( | ServiceReachableCallback | callback | ) |
Registers service reachable callback.
callback | the callback to configure. |
void kanzi::connect::AbstractInterfaceClient::setSessionRunning | ( | AbstractSessionSharedPtr | session | ) |
Set the given session to running state.
session | The session to set |
void kanzi::connect::AbstractInterfaceClient::setSessionStopped | ( | AbstractSessionSharedPtr | session | ) |
Set the given session to stopped state.
session | The session to set |
void kanzi::connect::AbstractInterfaceClient::stopAllSessions | ( | ) |
Ends all sessions since maybe the service itself has disappeared.
void kanzi::connect::AbstractInterfaceClient::terminateAllSessions | ( | ) |
Terminates all ongoing sessions.
|
protected |