Kanzi Connect  3.9.9
Kanzi Connect C++ API
kanzi::connect::LocalServiceHost Class Reference

A class that manages a service that is running locally in Kanzi Connect Server. More...

#include <service_host.hpp>

Inheritance diagram for kanzi::connect::LocalServiceHost:
kanzi::connect::ServiceHost

Public Member Functions

 LocalServiceHost (const persistence::SettingFactory *settingFactory, VirtualFileClient *fileClient, const string &type, AbstractServiceSharedPtr service, ServiceRuntimeDataRegistrySharedPtr registry=ServiceRuntimeDataRegistrySharedPtr())
 Constructor. More...
 
virtual ~LocalServiceHost () override
 Destructor. More...
 
virtual string getIdentifier () const override
 Retrieve interface identifier. More...
 
virtual void changeType (const string &type) override
 Changes the interface name at runtime. More...
 
virtual void initialize (InterfaceDomainBase *domain, ContentClientSharedPtr contentClient, WorkQueueInterface *workQueue) override
 Initialize the service. More...
 
virtual void uninitialize () override
 cleanup the service. More...
 
virtual AbstractSessionSharedPtr acquireSession (ConnectedClientSharedPtr client, int sessionId) override
 Creates a session to this service. More...
 
virtual void releaseSession (int clientId, int sessionId) override
 Releases a session. More...
 
virtual void work (ConnectWorkItemSharedPtr workItem) 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) override
 Invoked for each message this service should handle. More...
 
virtual void notifyClientDisconnected (int clientId) override
 Invoked to inform that specific client has disconnected. More...
 
virtual const AbstractService::ServiceDescriptiongetDescription () override
 Retrieve the service description from service host. More...
 
virtual const AbstractService::ServiceStategetState () override
 Retrieve the service state information. More...
 
virtual bool local () const override
 Is this service local or not. More...
 
virtual int clientID () const override
 Returns the client identifier. More...
 
virtual void setState (const AbstractService::ServiceState &state) override
 Sets the service state. More...
 
virtual shared_ptr< ServiceServiceConcept::Session > getServiceSession () const override
 Returns a session to remote service. More...
 
virtual AbstractServiceSharedPtr getService () const override
 Returns a service instance. More...
 
virtual int countSessions () const override
 Returns amount of sessions towards this service. More...
 
virtual ClientDescriptorSharedPtr getClientDescriptor () override
 Return the client descriptor. More...
 
virtual RuntimeDataObjectSharedPtr getConfigurationProperties () override
 Retrieve service configuration properties. More...
 
virtual string getServiceRoutingInformationDescription (int serverclientid) override
 Must be overridden by the corresponding implementation. More...
 
virtual void notifyAll (const MessagePackage &event) override
 Internal API for across service scripting, not for public use. More...
 
virtual RuntimeDataObjectgetRuntimeData () override
 Internal API for across service scripting, not for public use. More...
 
- Public Member Functions inherited from kanzi::connect::ServiceHost
virtual void ensureDomain (ConnectDomainSharedPtr domain)
 Ensure that service instance (if local) has domain set. More...
 
virtual const string getHash ()
 
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...
 
virtual bool reportServiceRuntimeData (const string &path, const string &stream)
 Can be called, mainly for remote services, to inform about new service information that was received. More...
 
 ServiceHost (ServiceRuntimeDataRegistrySharedPtr registry=ServiceRuntimeDataRegistrySharedPtr())
 C++ constructor. More...
 
virtual void setConfigurationProperties (RuntimeDataObjectSharedPtr properties)
 Stores service configuration properties. More...
 
virtual void setConfigurationPropertyChangedCallback (ConfigurationPropertyChangedCallback callback)
 Install a callback to be invoked when configuration property changes. More...
 
virtual void setHash (const string hash)
 
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) override
 

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 locally in Kanzi Connect Server.

Constructor & Destructor Documentation

◆ LocalServiceHost()

kanzi::connect::LocalServiceHost::LocalServiceHost ( const persistence::SettingFactory *  settingFactory,
VirtualFileClient fileClient,
const string &  type,
AbstractServiceSharedPtr  service,
ServiceRuntimeDataRegistrySharedPtr  registry = ServiceRuntimeDataRegistrySharedPtr() 
)

Constructor.

◆ ~LocalServiceHost()

virtual kanzi::connect::LocalServiceHost::~LocalServiceHost ( )
overridevirtual

Destructor.

Member Function Documentation

◆ acquireSession()

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

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::LocalServiceHost::changeType ( const string &  type)
overridevirtual

Changes the interface name at runtime.

Parameters
typenew type for the interface.

Implements kanzi::connect::ServiceHost.

◆ clientID()

virtual int kanzi::connect::LocalServiceHost::clientID ( ) const
overridevirtual

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::LocalServiceHost::countSessions ( ) const
overridevirtual

Returns amount of sessions towards this service.

Returns
amount of sessions

Implements kanzi::connect::ServiceHost.

◆ getClientDescriptor()

virtual ClientDescriptorSharedPtr kanzi::connect::LocalServiceHost::getClientDescriptor ( )
overridevirtual

Return the client descriptor.

Relevant only for remote services.

Returns
client descriptor

Implements kanzi::connect::ServiceHost.

◆ getConfigurationProperties()

virtual RuntimeDataObjectSharedPtr kanzi::connect::LocalServiceHost::getConfigurationProperties ( )
overridevirtual

Retrieve service configuration properties.

Returns
properties as shared object.

Implements kanzi::connect::ServiceHost.

◆ getDescription()

virtual const AbstractService::ServiceDescription& kanzi::connect::LocalServiceHost::getDescription ( )
overridevirtual

Retrieve the service description from service host.

Returns
const reference to service description

Implements kanzi::connect::ServiceHost.

◆ getIdentifier()

virtual string kanzi::connect::LocalServiceHost::getIdentifier ( ) const
overridevirtual

Retrieve interface identifier.

Returns
interface ID this service handles.

Implements kanzi::connect::ServiceHost.

◆ getRuntimeData()

virtual RuntimeDataObject* kanzi::connect::LocalServiceHost::getRuntimeData ( )
inlineoverridevirtual

Internal API for across service scripting, not for public use.

Request a pointer to service host runtime data. Returned data (if any) may be a mirror to a service registry so modifying values here may not be visible for the hosted service itself.

Reimplemented from kanzi::connect::ServiceHost.

◆ getService()

virtual AbstractServiceSharedPtr kanzi::connect::LocalServiceHost::getService ( ) const
overridevirtual

Returns a service instance.

Relevant only for local services.

Returns
service

Implements kanzi::connect::ServiceHost.

◆ getServiceDescriptionSchemaImpl()

virtual void kanzi::connect::LocalServiceHost::getServiceDescriptionSchemaImpl ( string &  output)
overrideprotectedvirtual

◆ getServiceRoutingInformationDescription()

virtual string kanzi::connect::LocalServiceHost::getServiceRoutingInformationDescription ( int  serverclientid)
overridevirtual

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::LocalServiceHost::getServiceSession ( ) const
inlineoverridevirtual

Returns a session to remote service.

Relevant only for remote services.

Returns
session

Implements kanzi::connect::ServiceHost.

◆ getState()

virtual const AbstractService::ServiceState& kanzi::connect::LocalServiceHost::getState ( )
overridevirtual

Retrieve the service state information.

Returns
const reference to service state information.

Implements kanzi::connect::ServiceHost.

◆ initialize()

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

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.

◆ local()

virtual bool kanzi::connect::LocalServiceHost::local ( ) const
overridevirtual

Is this service local or not.

Returns
true if service is local

Implements kanzi::connect::ServiceHost.

◆ notifyAll()

virtual void kanzi::connect::LocalServiceHost::notifyAll ( const MessagePackage event)
inlineoverridevirtual

Internal API for across service scripting, not for public use.

Notify all client sessions with message.

Reimplemented from kanzi::connect::ServiceHost.

◆ notifyClientDisconnected()

virtual void kanzi::connect::LocalServiceHost::notifyClientDisconnected ( int  clientId)
overridevirtual

Invoked to inform that specific client has disconnected.

Parameters
clientIdIdentifies the client.

Implements kanzi::connect::ServiceHost.

◆ receiveMessage()

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

Invoked for each message this service should handle.

Parameters
clientidentifies the message sender
messagethe message to process.

Implements kanzi::connect::ServiceHost.

◆ releaseSession()

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

Releases a session.

Parameters
clientIdidentifies the client
sessionIdidentifies the session

Implements kanzi::connect::ServiceHost.

◆ setState()

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

Sets the service state.

Relevant only for remote clients.

Parameters
statenew state for remote clients.

Implements kanzi::connect::ServiceHost.

◆ uninitialize()

virtual void kanzi::connect::LocalServiceHost::uninitialize ( )
overridevirtual

cleanup the service.

Implements kanzi::connect::ServiceHost.

◆ work()

virtual void kanzi::connect::LocalServiceHost::work ( ConnectWorkItemSharedPtr  workItem)
overridevirtual

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: