本文整理汇总了C++中WebServer::print方法的典型用法代码示例。如果您正苦于以下问题:C++ WebServer::print方法的具体用法?C++ WebServer::print怎么用?C++ WebServer::print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebServer
的用法示例。
在下文中一共展示了WebServer::print方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: helloCmd
/* commands are functions that get called by the webserver framework
* they can read any posted data from client, and they output to the
* server to send data back to the web browser. */
void helloCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
/* this line sends the standard "we're all OK" headers back to the
browser */
server.httpSuccess();
/* if we're handling a GET or POST, we can output our data here.
For a HEAD request, we just stop after outputting headers. */
if (type != WebServer::HEAD)
{
/* this defines some HTML text in read-only memory aka PROGMEM.
* This is needed to avoid having the string copied to our limited
* amount of RAM. */
const char *helloMsg = "<html><body><h1>Hello, Costanza!</h1></body></html>";
/* this is a special form of print that outputs from PROGMEM */
server.print(helloMsg);
}
}
示例2: getStateCmd
void WebManager::getStateCmd(WebServer& server, WebServer::ConnectionType type, char* url_tail, bool tail_complete) {
#ifdef PRINT_DEBUG_MSGS
Serial.println("ajax_refresh");
#endif
if (getInstance()->m_webserver->checkCredentials(IOManager::getInstance()->m_credentialsFile->m_authCredentials)) {
/* for a GET or HEAD, send the standard "it's all OK headers" */
server.httpSuccess();
server.print("{'state': ");
server.print(DoorStateManager::getInstance()->m_currentState->getId());
server.print(", 'obstacle': ");
server.print(DoorStateManager::getInstance()->isObstacleDetected() ? "true" : "false");
server.print(", 'forgottenOpened': ");
server.print(DoorStateManager::getInstance()->isForgottenOpenedDoor() ? "true" : "false");
server.print('}');
} else {
/* send a 401 error back causing the web browser to prompt the user for credentials */
server.httpUnauthorized();
}
}