A service class to manage clients on server side. Implements Connection Interface on server.
More...
#include <virtualfile_service.hpp>
|
| virtual void | cancelRequestResource (const string &uri) override |
| |
| virtual void | fileBlock (const int &requestHandle, const int &ordinal, const string &data) override |
| |
| virtual void | onReleaseSession (AbstractSessionSharedPtr session) override |
| |
| virtual bool | processFileReadRequest (struct mg_connection *connection) override |
| | Invoked to handle a content request.
|
| |
| virtual bool | processPostContentRequest (struct mg_connection *connection) override |
| | Invoked to handle HTTP post request.
|
| |
| bool | processRequestInternal (struct mg_connection *connection, const string &uri) |
| |
| virtual void | provideAsFileThroughHttp (VirtualFileWorkItemSharedPtr workItem, const string &filepath) override |
| | Provide response as a path to existing file.
|
| |
| virtual void | provideAsHttpContent (VirtualFileWorkItemSharedPtr workItem, const string &mime, const unsigned char *blob, size_t length) override |
| | Provide requested file as inline content through HTTP.
|
| |
| virtual void | provideAsRedirectUri (VirtualFileWorkItemSharedPtr workItem, const string &redirecturi) override |
| | Provide response as HTTP redirect.
|
| |
| virtual bool | provideFileAsData (const int &requestHandle, const string &mime, const string &content) override |
| |
| virtual bool | provideFileAsFilepath (const int &requestHandle, const string &mime, const string &filepath) override |
| |
| virtual bool | provideFileAsHttpRedirect (const int &requestHandle, const string &redirecturi) override |
| |
| virtual bool | provideFileDirectly (const string &uri, vector< char > &buffer, const unsigned int blockSize) override |
| | Provide response as file contents through the connection adapters.
|
| |
| virtual string | registerPath (const string &scheme, const string &path) override |
| |
| virtual bool | requestResource (const string &uri) override |
| |
| virtual void | startFileResponse (const int &requestHandle, const int &blockSize, const int &numBlocks) override |
| |
| virtual bool | unregisterPath (const string &path) override |
| |
A service class to manage clients on server side. Implements Connection Interface on server.
◆ VirtualFileService()
C++ constructor - initialize the object.
- Parameters
-
| domain | connect domain instance. |
◆ ~VirtualFileService()
| virtual kanzi::connect::VirtualFileService::~VirtualFileService |
( |
| ) |
|
|
virtual |
◆ cancelRequestResource()
| virtual void kanzi::connect::VirtualFileService::cancelRequestResource |
( |
const string & | uri | ) |
|
|
overrideprotectedvirtual |
◆ fileBlock()
| virtual void kanzi::connect::VirtualFileService::fileBlock |
( |
const int & | requestHandle, |
|
|
const int & | ordinal, |
|
|
const string & | data ) |
|
overrideprotectedvirtual |
◆ initialize()
◆ onReleaseSession()
◆ prepareForShutdown()
| void kanzi::connect::VirtualFileService::prepareForShutdown |
( |
| ) |
|
Tell service that system is about to uninitialize, and no new requests should be added.
◆ processFileReadRequest()
| virtual bool kanzi::connect::VirtualFileService::processFileReadRequest |
( |
struct mg_connection * | connection | ) |
|
|
overrideprotectedvirtual |
◆ processPostContentRequest()
| virtual bool kanzi::connect::VirtualFileService::processPostContentRequest |
( |
struct mg_connection * | connection | ) |
|
|
overrideprotectedvirtual |
◆ processRequestInternal()
| bool kanzi::connect::VirtualFileService::processRequestInternal |
( |
struct mg_connection * | connection, |
|
|
const string & | uri ) |
|
protected |
◆ processWork()
Process a work item from other services.
- Parameters
-
| workItem | Connect work item to process and report status. |
◆ provideAsFileThroughHttp()
| virtual void kanzi::connect::VirtualFileService::provideAsFileThroughHttp |
( |
VirtualFileWorkItemSharedPtr | workItem, |
|
|
const string & | filepath ) |
|
overrideprotectedvirtual |
◆ provideAsHttpContent()
| virtual void kanzi::connect::VirtualFileService::provideAsHttpContent |
( |
VirtualFileWorkItemSharedPtr | workItem, |
|
|
const string & | mime, |
|
|
const unsigned char * | blob, |
|
|
size_t | length ) |
|
overrideprotectedvirtual |
◆ provideAsRedirectUri()
◆ provideFileAsData()
| virtual bool kanzi::connect::VirtualFileService::provideFileAsData |
( |
const int & | requestHandle, |
|
|
const string & | mime, |
|
|
const string & | content ) |
|
overrideprotectedvirtual |
◆ provideFileAsFilepath()
| virtual bool kanzi::connect::VirtualFileService::provideFileAsFilepath |
( |
const int & | requestHandle, |
|
|
const string & | mime, |
|
|
const string & | filepath ) |
|
overrideprotectedvirtual |
◆ provideFileAsHttpRedirect()
| virtual bool kanzi::connect::VirtualFileService::provideFileAsHttpRedirect |
( |
const int & | requestHandle, |
|
|
const string & | redirecturi ) |
|
overrideprotectedvirtual |
◆ provideFileDirectly()
| virtual bool kanzi::connect::VirtualFileService::provideFileDirectly |
( |
const string & | uri, |
|
|
vector< char > & | buffer, |
|
|
const unsigned int | blockSize ) |
|
overrideprotectedvirtual |
Provide response as file contents through the connection adapters.
- Parameters
-
| uri | Identifies the file |
| buffer | The data to provide |
| blockSize | Defines in what size chunks to send the file contents |
- Returns
- bool indicating whether file transfer was initiated.
Implements kanzi::connect::VirtualFileLocalResponseInterface.
◆ registerPath() [1/2]
| virtual string kanzi::connect::VirtualFileService::registerPath |
( |
const string & | scheme, |
|
|
const string & | path ) |
|
overrideprotectedvirtual |
◆ registerPath() [2/2]
| string kanzi::connect::VirtualFileService::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.
◆ requestResource()
| virtual bool kanzi::connect::VirtualFileService::requestResource |
( |
const string & | uri | ) |
|
|
overrideprotectedvirtual |
◆ setHttpServer()
Set HTTP server to handle HTTP requests.
- Parameters
-
| httpServer | HTTP server to handle HTTP requests. |
◆ startFileResponse()
| virtual void kanzi::connect::VirtualFileService::startFileResponse |
( |
const int & | requestHandle, |
|
|
const int & | blockSize, |
|
|
const int & | numBlocks ) |
|
overrideprotectedvirtual |
◆ uninitialize()
| virtual void kanzi::connect::VirtualFileService::uninitialize |
( |
| ) |
|
|
overridevirtual |
◆ unregisterPath() [1/2]
| virtual bool kanzi::connect::VirtualFileService::unregisterPath |
( |
const string & | path | ) |
|
|
overrideprotectedvirtual |
◆ unregisterPath() [2/2]
| bool kanzi::connect::VirtualFileService::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.
The documentation for this class was generated from the following file:
- virtualfile_service/virtualfile_service.hpp