ConnectDomain

class kanzi::connect::ConnectDomain : public enable_shared_from_this<ConnectDomain>

Domain definition for Kanzi Connect.

Public Functions

ConnectDomain()

C++ constructor.

~ConnectDomain()
void cancelTimer(int64_t handle)

Cancel running timer.

Parameters
  • handle: timer identifier.

ClientRemoteServiceHostInterface *getClientRemoteServiceHostInterface() const

Retrieve remote service host interface.

Return

pointer to remote service host interface. nullptr if run in context where its not available.

ModuleSharedPtr getModule(const string &name)

Lookup module by name.

Return

shared pointer to module with the name

Parameters
  • name: the name of the module

ObjectFactory *getObjectFactory() const

Retrieve object factory instance.

Return

pointer to object factory. ownership not transfered.

PolicyContextInterface *getPolicyContext()

Return the policy context object.

Return

pointer to policy context. ownership not transfered.

SecurityContextInterface *getSecurityContext()

Return the security context object.

Return

pointer to security context. ownership not transfered.

ServerConfig *getServerConfig()

Get server configuration handler.

Return

pointer to server configuration. ownership not transfered.

ServerState *getServerState()

Get server state handler.

Return

pointer to server state. ownership not transfered.

LocalServiceDiscoveryInterface *getServiceLookup() const

Retrieve the interface used to perform service lookup.

Return

pointer to functionality that can be used to discover service within the local system.

WebSocketContextInterface *getWebSocketContext()

Return the websocket context object.

Return

pointer to websocket context. ownership not transfered.

bool loadModule(const string &modulename)

Loads a dynamic module from library.

Return

true if successfully loaded, false if some error determined.

Parameters
  • modulename: base for library name. No extension (libXXX.so, .dll) allowed..

template<class _TModuleType>
bool registerModule(const string &name)

Template method to register a typed module into the system.

Return

true if registration successful, false on error.

Parameters
  • name: the name of the module to register

void setClientRemoteServiceHostInterface(ClientRemoteServiceHostInterface &rshInterface)

Configure remoteservicehost interface.

Parameters
  • rshInterface: the interface to register.

void setServiceLookupInterface(LocalServiceDiscoveryInterface *lookupInterface)

Configure service lookup interface.

Parameters
  • lookupInterface: the service lookup interface.

int64_t setTimer(int ms, ConnectWorkItem::Executor executable)

Schedules an executable object to be run in future.

Execution conext for the executable is such that it is allowed to use any kanzi connect API’s from it.

Return

handle to timer. This handle is valid (valid if != 0) if timeout is provided and can be used to cancel the object later on.

domain->setTimer(0, [](){ printf("Hey!\n"); });

Parameters
  • ms: timeout after which the executable is launched. Passing <= 0 indicates that object should be executed as soon as possible.

  • executable: executable object that is to be invoked.

void setWorkDispatcher(WorkQueueInterface *dispatcher)

Configure work item dispatcher to the domain.

Parameters
  • dispatcher: work item dispatcher.

bool unloadModule(const string &modulename)

Unloads a dynamic module from library.

Return

true if successfully unloaded, false if some error determined.

Parameters
  • modulename: base for library name. No extension (libXXX.so, .dll) allowed..

Public Static Functions

ConnectDomainSharedPtr create()

Creates a default domain instance without configuration file.

This creates a stub server without any services or outgoing bearers so not much functional

Return

newly allocated connect domain

ConnectDomainSharedPtr create(const string configurationFile)

Creates an instance of connect domain.

Return

connect domain instance.

Parameters
  • configurationFile: the configuration file for server.

ConnectDomainSharedPtr create(FileSet &fileset)

Creates an instance of connect domain.

Return

connect domain instance.

Parameters
  • fileset: set of configuration files passed during the construction

ConnectDomainSharedPtr createForClient(const string configurationFile = string())

Creates a reduced connect domain object to be used on client side.

Return

newly allocation connect domain instance.

Parameters
  • configurationFile: optional configuration filename to be used to initialize for example policy functionality.