int DistributedClient::clp_handler_impl::submit(client::configuration::data_type data, const Plugin::SubmitRequestMessage &request_message, std::string &reply) { const ::Plugin::Common_Header& request_header = request_message.header(); int ret = NSCAPI::returnUNKNOWN; connection_data con = parse_header(request_header, data); Plugin::SubmitResponseMessage response_message; nscapi::functions::make_return_header(response_message.mutable_header(), request_header); std::list<nscp::packet> chunks; chunks.push_back(nscp::factory::create_payload(nscp::data::command_response, request_message.SerializeAsString(), 0)); chunks = instance->send(con, chunks); BOOST_FOREACH(nscp::packet &chunk, chunks) { if (nscp::checks::is_submit_response(chunk)) { nscapi::functions::append_response_payloads(response_message, chunk.payload); } else if (nscp::checks::is_error(chunk)) { std::string error = gather_and_log_errors(chunk.payload); nscapi::functions::append_simple_submit_response_payload(response_message.add_payload(), "", NSCAPI::returnUNKNOWN, error); ret = NSCAPI::returnUNKNOWN; } else { NSC_LOG_ERROR_STD(_T("Unsupported message type: ") + strEx::itos(chunk.signature.payload_type)); nscapi::functions::append_simple_submit_response_payload(response_message.add_payload(), "", NSCAPI::returnUNKNOWN, "Unsupported response type"); ret = NSCAPI::returnUNKNOWN; } } response_message.SerializeToString(&reply); return ret; }
int NSCPClient::clp_handler_impl::submit(client::configuration::data_type data, const Plugin::SubmitRequestMessage &request_message, Plugin::SubmitResponseMessage &response_message) { const ::Plugin::Common_Header& request_header = request_message.header(); connection_data con = parse_header(request_header, data); std::string tmp; int ret = send(con, NSCPIPC::Common_MessageTypes_SUBMIT_REQUEST, request_message.SerializeAsString(), tmp); response_message.ParseFromString(tmp); return ret; }