Kanzi Connect  1.1.10
Kanzi Connect C++ API
kanzi::connect::RemoteServiceHost Class Reference

A class that manages a service that is running remotely over the network. More...

#include <service_host.hpp>

Inheritance diagram for kanzi::connect::RemoteServiceHost:
kanzi::connect::ServiceHost

Public Member Functions

void initializeFlowControl (int credits, int creditreturninterval)
 Initialize flow control object. More...
 
bool registerRoutingInformationSchema (const string &schema)
 Register routing information schema. More...
 
bool registerServiceDescriptionSchema (const string &schema)
 Invoked to register service description xml. More...
 
 RemoteServiceHost (const string &type, shared_ptr< ServiceServiceConcept::Session > serviceSession, ServiceRuntimeDataRegistrySharedPtr registry=ServiceRuntimeDataRegistrySharedPtr())
 Constructor. More...
 
void setClientDescriptor (ClientDescriptorSharedPtr clientDescription)
 Sets a client descriptor. More...
 
void setDescription (const AbstractService::ServiceDescription &description)
 Set service description for a remote service. More...
 
virtual ~RemoteServiceHost () KZ_OVERRIDE
 Destructor. More...
 
virtual string getIdentifier () const KZ_OVERRIDE
 Retrieve interface identifier. More...
 
virtual void changeType (const string &type) KZ_OVERRIDE
 Changes the interface name at runtime. More...
 
virtual void initialize (InterfaceDomainBase *domain, ContentClientSharedPtr contentClient, WorkQueueInterface *workQueue) KZ_OVERRIDE
 Initialize the service. More...
 
virtual void uninitialize () KZ_OVERRIDE
 cleanup the service. More...
 
virtual AbstractSessionSharedPtr acquireSession (ConnectedClientSharedPtr client, int sessionId) KZ_OVERRIDE
 Creates a session to this service. More...
 
virtual void releaseSession (int clientId, int sessionId) KZ_OVERRIDE
 Releases a session. More...
 
virtual void work (ConnectWorkItemSharedPtr workItem) KZ_OVERRIDE
 Routine that get(s) called periodically or especially when object itself has requested it to be called using the work queue. More...
 
virtual void receiveMessage (ConnectedClientSharedPtr client, const MessagePackage &message) KZ_OVERRIDE
 Invoked for each message this service should handle. More...
 
virtual void notifyClientDisconnected (int clientId) KZ_OVERRIDE
 Invoked to inform that specific client has disconnected. More...
 
virtual const AbstractService::ServiceDescriptiongetDescription () KZ_OVERRIDE
 Retrieve the service description from service host. More...
 
virtual const AbstractService::ServiceStategetState () KZ_OVERRIDE
 Retrieve the service state information. More...
 
virtual bool local () const KZ_OVERRIDE
 Is this service local or not. More...
 
virtual shared_ptr< ServiceServiceConcept::Session > getServiceSession () const KZ_OVERRIDE
 Returns a session to remote service. More...
 
virtual int clientID () const KZ_OVERRIDE
 Returns the client identifier. More...
 
virtual AbstractServiceSharedPtr getService () const KZ_OVERRIDE
 Returns a service instance. More...
 
virtual int countSessions () const KZ_OVERRIDE
 Returns amount of sessions towards this service. More...
 
virtual ClientDescriptorSharedPtr getClientDescriptor () KZ_OVERRIDE
 Return the client descriptor. More...
 
virtual void setConfigurationProperties (RuntimeDataObjectSharedPtr properties) KZ_OVERRIDE
 Stores service configuration properties. More...
 
virtual RuntimeDataObjectSharedPtr getConfigurationProperties () KZ_OVERRIDE
 Retrieve service configuration properties. More...
 
virtual void setState (const AbstractService::ServiceState &state) KZ_OVERRIDE
 Sets the service state. More...
 
virtual string getServiceRoutingInformationDescription (int serverclientid) KZ_OVERRIDE
 Must be overridden by the corresponding implementation. More...
 
virtual bool reportServiceRuntimeData (const string &, const string &) KZ_OVERRIDE
 Can be called, mainly for remote services, to inform about new service information that was received. More...
 
virtual void notifyAll (const MessagePackage &event) KZ_OVERRIDE
 Internal API for scripting utilities makes assumptions on implementation details. More...
 
virtual RuntimeDataObjectgetRuntimeData () KZ_OVERRIDE
 Internal API for scripting utilities makes assumptions on implementation details. More...
 
- Public Member Functions inherited from kanzi::connect::ServiceHost
virtual void ensureDomain (ConnectDomain *domain)
 Ensure that service instance (if local) has domain set. More...
 
virtual const string getServiceDescriptionSchema (bool details=false)
 Retrieve service description schema. More...
 
virtual bool registerServiceRuntimeData (const string schema="")
 Invoked to register service runtime data. More...
 
virtual bool registerServiceRuntimeDataSchemaChange (const string &xml)
 Invoked to change runtime data schema at runtime. More...
 
 ServiceHost (ServiceRuntimeDataRegistrySharedPtr registry=ServiceRuntimeDataRegistrySharedPtr())
 C++ constructor. More...
 
virtual void setConfigurationPropertyChangedCallback (ConfigurationPropertyChangedCallback callback)
 Install a callback to be invoked when configuration property changes. More...
 
bool subscribeForRuntimeDataSchemaChanges (GenericSyncObserver<> &observer)
 Start getting notifications of runtime data schema changes. More...
 
bool unsubscribeForRuntimeDataSchemaChanges (GenericSyncObserver<> &observer)
 Stop receiving notifications of runtime data schema changes. More...
 
virtual ~ServiceHost ()
 Destructor. More...
 

Protected Member Functions

virtual void getServiceDescriptionSchemaImpl (string &output) KZ_OVERRIDE
 
AbstractSessionSharedPtr getSession (int clientId, int sessionId)
 

Additional Inherited Members

- Public Types inherited from kanzi::connect::ServiceHost
typedef function< void(ServiceHost *, RuntimeDataObjectSharedPtr)> ConfigurationPropertyChangedCallback
 Callback prototype to invoke when service configuration properties change. More...
 
- Protected Attributes inherited from kanzi::connect::ServiceHost
ConfigurationPropertyChangedCallback m_configurationPropertyChangedCallback
 
unique_ptr< RuntimeDataChildChangeMonitorm_configurationPropertyChangeMonitor
 
ServiceRuntimeDataRegistry::ContentRegistrationToken m_runtimeDataRegistrationToken
 
ServiceRuntimeDataRegistrySharedPtr m_runtimeDataRegistry
 Runtime data registry for convenient access. More...
 
GenericSyncPublisher m_runtimeDataSchemaChangePublisher
 Publisher to use when runtime data schema changes within the ServiceHost. More...
 
AbstractService::RuntimeDataSchemaChangeSubscriptionToken m_runtimeDataSchemaChangeSubscriptionToken
 

Detailed Description

A class that manages a service that is running remotely over the network.

Constructor & Destructor Documentation

◆ RemoteServiceHost()

kanzi::connect::RemoteServiceHost::RemoteServiceHost ( const string &  type,
shared_ptr< ServiceServiceConcept::Session >  serviceSession,
ServiceRuntimeDataRegistrySharedPtr  registry = ServiceRuntimeDataRegistrySharedPtr() 
)

Constructor.

Parameters
typethe service interface identifier
serviceSessionpointer to session. Ownership does not transfer.

◆ ~RemoteServiceHost()

virtual kanzi::connect::RemoteServiceHost::~RemoteServiceHost ( )
virtual

Destructor.

Member Function Documentation

◆ acquireSession()

virtual AbstractSessionSharedPtr kanzi::connect::RemoteServiceHost::acquireSession ( ConnectedClientSharedPtr  client,
int  sessionId 
)
virtual

Creates a session to this service.

Parameters
clientidentifies the client.
sessionIdidentifies the session.
Returns
session instance. ownership not transfered.

Implements kanzi::connect::ServiceHost.

◆ changeType()

virtual void kanzi::connect::RemoteServiceHost::changeType ( const string &  type)
virtual

Changes the interface name at runtime.

Parameters
typenew type for the interface.

Implements kanzi::connect::ServiceHost.

◆ clientID()

virtual int kanzi::connect::RemoteServiceHost::clientID ( ) const
virtual

Returns the client identifier.

Relevant only for remote clients. Will return -1 for local clients.

Returns
client identifier.

Implements kanzi::connect::ServiceHost.

◆ countSessions()

virtual int kanzi::connect::RemoteServiceHost::countSessions ( ) const
virtual

Returns amount of sessions towards this service.

Returns
amount of sessions

Implements kanzi::connect::ServiceHost.

◆ getClientDescriptor()

virtual ClientDescriptorSharedPtr kanzi::connect::RemoteServiceHost::getClientDescriptor ( )
virtual

Return the client descriptor.

Relevant only for remote services.

Returns
client descriptor

Implements kanzi::connect::ServiceHost.

◆ getConfigurationProperties()

virtual RuntimeDataObjectSharedPtr kanzi::connect::RemoteServiceHost::getConfigurationProperties ( )
virtual

Retrieve service configuration properties.

Returns
properties as shared object.

Implements kanzi::connect::ServiceHost.

◆ getDescription()

virtual const AbstractService::ServiceDescription& kanzi::connect::RemoteServiceHost::getDescription ( )
virtual

Retrieve the service description from service host.

Returns
const reference to service description

Implements kanzi::connect::ServiceHost.

◆ getIdentifier()

virtual string kanzi::connect::RemoteServiceHost::getIdentifier ( ) const
virtual

Retrieve interface identifier.

Returns
interface ID this service handles.

Implements kanzi::connect::ServiceHost.

◆ getRuntimeData()

virtual RuntimeDataObject* kanzi::connect::RemoteServiceHost::getRuntimeData ( )
inlinevirtual

Internal API for scripting utilities makes assumptions on implementation details.

Do not use.

Reimplemented from kanzi::connect::ServiceHost.

◆ getService()

virtual AbstractServiceSharedPtr kanzi::connect::RemoteServiceHost::getService ( ) const
inlinevirtual

Returns a service instance.

Relevant only for local services.

Returns
service

Implements kanzi::connect::ServiceHost.

◆ getServiceDescriptionSchemaImpl()

virtual void kanzi::connect::RemoteServiceHost::getServiceDescriptionSchemaImpl ( string &  output)
protectedvirtual

◆ getServiceRoutingInformationDescription()

virtual string kanzi::connect::RemoteServiceHost::getServiceRoutingInformationDescription ( int  serverclientid)
virtual

Must be overridden by the corresponding implementation.

Returns
xml format routing information for the service.

Implements kanzi::connect::ServiceHost.

◆ getServiceSession()

virtual shared_ptr<ServiceServiceConcept::Session> kanzi::connect::RemoteServiceHost::getServiceSession ( ) const
virtual

Returns a session to remote service.

Relevant only for remote services.

Returns
session

Implements kanzi::connect::ServiceHost.

◆ getSession()

AbstractSessionSharedPtr kanzi::connect::RemoteServiceHost::getSession ( int  clientId,
int  sessionId 
)
protected

◆ getState()

virtual const AbstractService::ServiceState& kanzi::connect::RemoteServiceHost::getState ( )
virtual

Retrieve the service state information.

Returns
const reference to service state information.

Implements kanzi::connect::ServiceHost.

◆ initialize()

virtual void kanzi::connect::RemoteServiceHost::initialize ( InterfaceDomainBase domain,
ContentClientSharedPtr  contentClient,
WorkQueueInterface workQueue 
)
virtual

Initialize the service.

Parameters
domainenvironment where the service is run in.
contentClientaccess to content system
workQueueinterface to work queue used to dispatch work service is ready will eventually cause the services work() method to be invoked.

Implements kanzi::connect::ServiceHost.

◆ initializeFlowControl()

void kanzi::connect::RemoteServiceHost::initializeFlowControl ( int  credits,
int  creditreturninterval 
)

Initialize flow control object.

Parameters
creditsamount of credits initially
creditreturnintervalhow often return credits to service.

◆ local()

virtual bool kanzi::connect::RemoteServiceHost::local ( ) const
virtual

Is this service local or not.

Returns
true if service is local

Implements kanzi::connect::ServiceHost.

◆ notifyAll()

virtual void kanzi::connect::RemoteServiceHost::notifyAll ( const MessagePackage event)
inlinevirtual

Internal API for scripting utilities makes assumptions on implementation details.

Do not use.

Reimplemented from kanzi::connect::ServiceHost.

◆ notifyClientDisconnected()

virtual void kanzi::connect::RemoteServiceHost::notifyClientDisconnected ( int  clientId)
virtual

Invoked to inform that specific client has disconnected.

Parameters
clientIdIdentifies the client.

Implements kanzi::connect::ServiceHost.

◆ receiveMessage()

virtual void kanzi::connect::RemoteServiceHost::receiveMessage ( ConnectedClientSharedPtr  client,
const MessagePackage message 
)
virtual

Invoked for each message this service should handle.

Parameters
clientidentifies the message sender
messagethe message to process.

Implements kanzi::connect::ServiceHost.

◆ registerRoutingInformationSchema()

bool kanzi::connect::RemoteServiceHost::registerRoutingInformationSchema ( const string &  schema)

Register routing information schema.

Parameters
routinginformation schema to register.
Returns
true if registration succeeds.

◆ registerServiceDescriptionSchema()

bool kanzi::connect::RemoteServiceHost::registerServiceDescriptionSchema ( const string &  schema)

Invoked to register service description xml.

Parameters
schemathe schema (xml)
Returns
true if registration succeeded.

◆ releaseSession()

virtual void kanzi::connect::RemoteServiceHost::releaseSession ( int  clientId,
int  sessionId 
)
virtual

Releases a session.

Parameters
clientIdidentifies the client
sessionIdidentifies the session

Implements kanzi::connect::ServiceHost.

◆ reportServiceRuntimeData()

virtual bool kanzi::connect::RemoteServiceHost::reportServiceRuntimeData ( const string &  ,
const string &   
)
virtual

Can be called, mainly for remote services, to inform about new service information that was received.

Reimplemented from kanzi::connect::ServiceHost.

◆ setClientDescriptor()

void kanzi::connect::RemoteServiceHost::setClientDescriptor ( ClientDescriptorSharedPtr  clientDescription)

Sets a client descriptor.

Parameters
clientDescriptionThe information to set.

◆ setConfigurationProperties()

virtual void kanzi::connect::RemoteServiceHost::setConfigurationProperties ( RuntimeDataObjectSharedPtr  )
virtual

Stores service configuration properties.

Default implementation is empty, should be overridden by the remote service host implementation

Parameters
propertiesdata object describing the properties.

Reimplemented from kanzi::connect::ServiceHost.

◆ setDescription()

void kanzi::connect::RemoteServiceHost::setDescription ( const AbstractService::ServiceDescription description)

Set service description for a remote service.

Parameters
descriptionthe description to set

◆ setState()

virtual void kanzi::connect::RemoteServiceHost::setState ( const AbstractService::ServiceState state)
virtual

Sets the service state.

Relevant only for remote clients.

Parameters
statenew state for remote clients.

Implements kanzi::connect::ServiceHost.

◆ uninitialize()

virtual void kanzi::connect::RemoteServiceHost::uninitialize ( )
virtual

cleanup the service.

Implements kanzi::connect::ServiceHost.

◆ work()

virtual void kanzi::connect::RemoteServiceHost::work ( ConnectWorkItemSharedPtr  workItem)
virtual

Routine that get(s) called periodically or especially when object itself has requested it to be called using the work queue.

Parameters
workItemItem to be processed.

Implements kanzi::connect::ServiceHost.


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