当前位置: 首页>>代码示例>>C++>>正文


C++ WebServer::print方法代码示例

本文整理汇总了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);
    }
}
开发者ID:corbinstreehouse,项目名称:Webduino,代码行数:23,代码来源:HelloWorld.cpp

示例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();
	}
}
开发者ID:NicolasLambert,项目名称:GarageDoor,代码行数:19,代码来源:WebManager.cpp


注:本文中的WebServer::print方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。