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(ConnectDomainSharedPtr domain = nullptr)

C++ constructor - initialize the object.

Parameters
  • domain: connect domain instance.

~VirtualFileService()

Destructor.

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

See AbstractService::initialize.

void prepareForShutdown()

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

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.

Return

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

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.

void setHttpServer(CivetServerSharedPtr httpServer)

Set HTTP server to handle HTTP requests.

Parameters
  • httpServer: HTTP server to handle HTTP requests.

void uninitialize() override

See AbstractService::uninitialize.

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

Unregisters previously registered path.

Both provided parameters must be provided.

Return

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

Parameters
  • path: The path to unregister.

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