本文整理汇总了C++中plugin::queryrequestmessage::Request::SerializeAsString方法的典型用法代码示例。如果您正苦于以下问题:C++ Request::SerializeAsString方法的具体用法?C++ Request::SerializeAsString怎么用?C++ Request::SerializeAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plugin::queryrequestmessage::Request
的用法示例。
在下文中一共展示了Request::SerializeAsString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua
void lua::lua_runtime::on_query(std::string command, script_information *information, lua::lua_traits::function_type function, bool simple, const Plugin::QueryRequestMessage::Request &request, Plugin::QueryResponseMessage::Response *response, const Plugin::QueryRequestMessage &request_message)
{
lua_wrapper lua(prep_function(information, function));
int args = 2;
if (function.object_ref != 0)
args = 3;
if (simple) {
std::list<std::string> argslist;
for (int i=0;i<request.arguments_size();i++)
argslist.push_back(request.arguments(i));
lua.push_string(command);
lua.push_array(argslist);
if (lua.pcall(args, 3, 0) != 0)
return nscapi::protobuf::functions::set_response_bad(*response, "Failed to handle command: " + command + ": " + lua.pop_string());
NSCAPI::nagiosReturn ret = NSCAPI::returnUNKNOWN;
if (lua.size() < 3) {
NSC_LOG_ERROR_STD("Invalid return: " + lua.dump_stack());
nscapi::protobuf::functions::append_simple_query_response_payload(response, command, NSCAPI::returnUNKNOWN, "Invalid return", "");
return;
}
std::string msg, perf;
perf = lua.pop_string();
msg = lua.pop_string();
ret = lua.pop_code();
lua.gc(LUA_GCCOLLECT, 0);
nscapi::protobuf::functions::append_simple_query_response_payload(response, command, ret, msg, perf);
} else {
lua.push_string(command);
lua.push_raw_string(request.SerializeAsString());
lua.push_raw_string(request_message.SerializeAsString());
args++;
if (lua.pcall(args, 1, 0) != 0)
return nscapi::protobuf::functions::set_response_bad(*response, "Failed to handle command: " + command + ": " + lua.pop_string());
if (lua.size() < 1) {
NSC_LOG_ERROR_STD("Invalid return: " + lua.dump_stack());
nscapi::protobuf::functions::append_simple_query_response_payload(response, command, NSCAPI::returnUNKNOWN, "Invalid return data", "");
return;
}
Plugin::QueryResponseMessage local_response;
std::string data = lua.pop_raw_string();
response->ParseFromString(data);
lua.gc(LUA_GCCOLLECT, 0);
}
}