本文整理汇总了C++中SocketClient::getFD方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketClient::getFD方法的具体用法?C++ SocketClient::getFD怎么用?C++ SocketClient::getFD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketClient
的用法示例。
在下文中一共展示了SocketClient::getFD方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: methodPost
bool HttpServer::methodPost(const SocketClient &client) {
std::string content;
if (StringConverter::getContentFrom(client.getMessage(), content)) {
std::string file;
if (StringConverter::getRequestedFile(client.getMessage(), file)) {
if (file.compare("/data.xml") == 0) {
// not used yet
} else if (file.compare("/streams.xml") == 0) {
_streams.fromXML(content);
} else if (file.compare("/config.xml") == 0) {
_properties.fromXML(content);
#ifdef LIBDVBCSA
} else if (file.compare("/dvbapi.xml") == 0) {
_streams.getDecrypt()->fromXML(content);
#endif
}
}
}
// setup reply
std::string htmlBody;
getHtmlBodyWithContent(htmlBody, HTML_NO_RESPONSE, "", CONTENT_TYPE_HTML, 0, 0);
// send 'htmlBody' to client
if (send(client.getFD(), htmlBody.c_str(), htmlBody.size(), 0) == -1) {
PERROR("send htmlBody");
return false;
}
return true;
}
示例2: copySocketClientAttr
void StreamClient::copySocketClientAttr(const SocketClient &socket) {
_rtspFD = socket.getFD();
_ip_addr = socket.getIPAddress();
_rtspMsg = socket.getMessage().c_str();
}
示例3: methodGet
//.........这里部分代码省略.........
file.erase(0, 1);
const std::string filePath = _properties.getWebPath() + "/" + file;
if (file.compare("data.xml") == 0) {
makeDataXML(docType);
docTypeSize = docType.size();
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
} else if (file.compare("streams.xml") == 0) {
makeStreamsXML(docType);
docTypeSize = docType.size();
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
} else if (file.compare(_properties.getFileName()) == 0) {
_properties.addToXML(docType);
docTypeSize = docType.size();
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
#ifdef LIBDVBCSA
} else if (file.compare(_streams.getDecrypt()->getFileName()) == 0) {
_streams.getDecrypt()->addToXML(docType);
docTypeSize = docType.size();
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
#endif
} else if (file.compare("log.xml") == 0) {
docType = make_log_xml();
docTypeSize = docType.size();
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
} else if (file.compare("STOP") == 0) {
exitRequest = true;
getHtmlBodyWithContent(htmlBody, HTML_NO_RESPONSE, "", CONTENT_TYPE_HTML, 0, 0);
} else if ((docTypeSize = readFile(filePath.c_str(), docType))) {
if (file.find(".xml") != std::string::npos) {
// check if the request is the SAT>IP description xml then fill in the server version, UUID and tuner string
if (docType.find("urn:ses-com:device") != std::string::npos) {
SI_LOG_DEBUG("Client: %s requesed %s", client.getIPAddress().c_str(), file.c_str());
// check did we get our desc.xml (we assume there are some %s in there)
if (docType.find("%s") != std::string::npos) {
docTypeSize -= 4 * 2; // minus 4x %s
docTypeSize += _properties.getDeliverySystemString().size();
docTypeSize += _properties.getUUID().size();
docTypeSize += _properties.getSoftwareVersion().size();
docTypeSize += _properties.getXSatipM3U().size();
char *doc_desc_xml = new char[docTypeSize + 1];
if (doc_desc_xml != nullptr) {
snprintf(doc_desc_xml, docTypeSize + 1, docType.c_str(), _properties.getSoftwareVersion().c_str(),
_properties.getUUID().c_str(), _properties.getDeliverySystemString().c_str(),
_properties.getXSatipM3U().c_str());
docType = doc_desc_xml;
DELETE_ARRAY(doc_desc_xml);
}
}
}
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_XML, docTypeSize, 0);
} else if (file.find(".html") != std::string::npos) {
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_HTML, docTypeSize, 0);
} else if (file.find(".js") != std::string::npos) {
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_JS, docTypeSize, 0);
} else if (file.find(".css") != std::string::npos) {
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_CSS, docTypeSize, 0);
} else if (file.find(".m3u") != std::string::npos) {
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_VIDEO, docTypeSize, 0);
} else if ((file.find(".png") != std::string::npos) ||
(file.find(".ico") != std::string::npos)) {
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_PNG, docTypeSize, 0);
} else {
getHtmlBodyWithContent(htmlBody, HTML_OK, file, CONTENT_TYPE_HTML, docTypeSize, 0);
}
} else {
file = _properties.getWebPath() + "/" + "404.html";
docTypeSize = readFile(file.c_str(), docType);
getHtmlBodyWithContent(htmlBody, HTML_NOT_FOUND, file, CONTENT_TYPE_HTML, docTypeSize, 0);
}
}
}
// send something?
if (docType.size() > 0) {
// SI_LOG_INFO("%s", htmlBody);
// send 'htmlBody' to client
if (send(client.getFD(), htmlBody.c_str(), htmlBody.size(), 0) == -1) {
PERROR("send htmlBody");
return false;
}
// send 'docType' to client
if (send(client.getFD(), docType.c_str(), docTypeSize, 0) == -1) {
PERROR("send docType");
return false;
}
return true;
}
// check did we have stop request
if (exitRequest) {
_properties.setExitApplication();
}
return false;
}