VirtualFileService

class kanzi::connect::VirtualFileService : public VirtualfileServiceConcept, public VirtualFileRequestHandler::ServiceInterface, public VirtualFileLocalResponseInterface

A service class to manage clients on server side. Implements Connection Interface on server.

Public Functions

VirtualFileService(ConnectDomain *domain = nullptr)

C++ constructor - initialize the object.

Parameters

domain – connect domain instance.

virtual ~VirtualFileService()

Destructor.

virtual void initialize (InterfaceDomainBase *domain, ContentClientSharedPtr contentClient, WorkQueueInterface *workQueue) KZ_OVERRIDE

See AbstractService::initialize.

void prepareForShutdown()

Tell service that system is about to uninitialize, and no new requests should be added.

virtual void processWork(VirtualFileWorkItemSharedPtr workItem)

Process a work item from other services.

Parameters

workItem – Connect work item to process and report status.

string registerPath(const string &scheme, const string &path, VirtualFileProvider *provider)

Registers a path to www server.

All requests towards the path will get forwarded to the provided file provider.

Parameters
  • scheme – Requested protocol. Either HTTP or HTTPS expected. If you do not set a value, uses HTTP.

  • path – Path to register. Registering a path camera produces URI like http://<server>:port/camera/ so served path always ends with ‘/’.

  • provider – The file provider. Caller ensures the lifetime of the object as long as the corresponding registration is alive.

Returns

Full path to the URI where the files are serviced. In case of duplicate registration or another error, returns an empty string.

void setHttpServer(CivetServerSharedPtr httpServer)

Set HTTP server to handle HTTP requests.

Parameters

httpServer – HTTP server to handle HTTP requests.

virtual void uninitialize () KZ_OVERRIDE

See AbstractService::uninitialize.

bool unregisterPath(const string &path, VirtualFileProvider *provider)

Unregisters previously registered path.

Both provided parameters must be provided.

Parameters
  • path – The path to unregister.

  • provider – The provider that was previously used to register the path.

Returns

If handler is unregistered, true. If the handler with the provided criteria cannot found, false.