|
httplib::Server & | server () |
| return the reference to the httplib::Server for any advanced operations. More...
|
|
int | port () |
| returns the port, assigned to the server More...
|
|
void | allowConsoleOutput (bool enable=true) |
| allows logging about every network action to the to cout More...
|
|
void | open (const Html &page) |
| opens the page in browser More...
|
|
void | openFile (const std::string &filepath) |
| opens the page from file in browser More...
|
|
void | get (requestHandler f, const char *pattern=nullptr) |
| assign the callback for the get request. The page may interact with the host program via the get requests. More...
|
|
void | post (requestHandler f, const char *pattern=nullptr) |
| assign the callback for the post request. The page may interact with the host program via the post requests. More...
|
|
void | put (requestHandler f, const char *pattern=nullptr) |
| assign the callback for the put request. More...
|
|
void | exchange (std::function< json::JSON(const json::JSON &)> f) |
| exchange objects, you are getting object as input and should return the object as well. The call of exchange initiated on browser's side by sendObject, see the example More...
|
|
void | listenAsync () |
| starts to listen the port. Usually, you don't need to call it manually. Any other network interaction function calls it. And if you will call it, nothing wrong will happen. If it was already called and listening thread created, then nothing happens. More...
|
|
void | signalToStop () |
| stop the server and exit the listen cycle. This function may be called in the response body. Server will be stopped only after the sending the response. More...
|
|
void | stopGracefully () |
| stop and wait till it will be stopped More...
|
|
bool | wait (int ms_amount=-1) |
| Wait till the page will be closed or the connection lost. Page treated as closed when there is no ping for 500 ms. More...
|
|
bool | alive (int ms_max=2000) |
| returns true if there sas ping from the page recently More...
|
|
double | msSincePing () |
| returns milliseconds since the last ping or < 0 if there was no pings. More...
|
|
Element & | console () |
|
Element & | el (const std::string &domElementID) |
|
Element & | eval () |
|
|
static void | setServerFilesPlacement (const char *path) |
| Set the path to the folder that contains /public folder The main.js should be placed into the root of that folder. If you will not specify the path, the folder that contains main.js will be taken as the root folder will be treated as the root folder for the server. More...
|
|
static std::string | path (const std::string &filename) |
| appends filename to the server files path, returns the absolute path More...
|
|
static void | read (const std::string &filename, std::string &to) |
| read the file to string, path is relative to server More...
|
|
static void | write (const std::string &filename, std::string &from) |
| write the string to file, path is relative to server More...
|
|
static void | createPath (const std::string &path) |
| create all componentes of the path, path is relative to server More...
|
|
static bool | pathIsRelative (const std::string &path) |
| detects if the path is relative to the server More...
|
|
This is the main class for interaction between the c++ code and the browser. The typical pattern is:
jcc::LocalSelver ls;
jcc::Html h("test.html");
ls.exchange([](const json::JSON& incomingData)->json::JSON {
json::JSON response;
return response;
});
ls.open(h);
do {
} while(ls.alive());
ls.finishGracefully(); *
void jcc::LocalServer::listenAsync |
( |
| ) |
|
|
inline |
starts to listen the port. Usually, you don't need to call it manually. Any other network interaction function calls it. And if you will call it, nothing wrong will happen. If it was already called and listening thread created, then nothing happens.
Referenced by exchange(), get(), open(), post(), put(), and wait().