本文整理汇总了C++中ConnectionManager::getTotalRequests方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionManager::getTotalRequests方法的具体用法?C++ ConnectionManager::getTotalRequests怎么用?C++ ConnectionManager::getTotalRequests使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionManager
的用法示例。
在下文中一共展示了ConnectionManager::getTotalRequests方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processMessage
int HttpServerMsgHandler::processMessage(void *arg) {
struct evhttp_request *req = (struct evhttp_request *)arg;
const char *cmdtype;
struct evkeyvalq *headers;
struct evkeyval *header;
switch (evhttp_request_get_command(req)) {
case EVHTTP_REQ_GET: cmdtype = "GET"; break;
case EVHTTP_REQ_POST: cmdtype = "POST"; break;
case EVHTTP_REQ_HEAD: cmdtype = "HEAD"; break;
case EVHTTP_REQ_PUT: cmdtype = "PUT"; break;
case EVHTTP_REQ_DELETE: cmdtype = "DELETE"; break;
case EVHTTP_REQ_OPTIONS: cmdtype = "OPTIONS"; break;
case EVHTTP_REQ_TRACE: cmdtype = "TRACE"; break;
case EVHTTP_REQ_CONNECT: cmdtype = "CONNECT"; break;
case EVHTTP_REQ_PATCH: cmdtype = "PATCH"; break;
default: cmdtype = "unknown"; break;
}
printf("Received a %s request for %s\nHeaders:\n",
cmdtype, evhttp_request_get_uri(req));
headers = evhttp_request_get_input_headers(req);
for (header = headers->tqh_first; header;
header = header->next.tqe_next) {
printf(" %s: %s\n", header->key, header->value);
}
ConnectionManager *conn = ConnectionManager::getInstance();
struct evbuffer *return_buffer=evbuffer_new();
long long total_req = conn->getTotalRequests();
long long total_res = conn->getTotalResponses();
unsigned int conns = conn->getConnections();
long long timeouts = conn->getTimeoutRequests();
long long err_res = conn->getErrorResponses();
long long conn_except = conn->getConnExceptions();
long long ok_res = conn->getOkResponses();
evbuffer_add_printf(return_buffer," total request: %lld<br> total response: %lld<br> connnections: %u<br><br><hr><br> ok: %lld \
<br> timeout: %lld<br> http error: %lld<br> connExcept: %u<br>"
, total_req, total_res, conns, ok_res, timeouts, err_res, conn_except);
evhttp_send_reply(req, HTTP_OK, "OK", return_buffer);
evbuffer_free(return_buffer);
return 0;
}