Example #1
0
std::string gather_and_log_errors(std::string  &payload) {
	NSCPIPC::ErrorMessage message;
	message.ParseFromString(payload);
	std::string ret;
	for (int i=0;i<message.error_size();i++) {
		ret += message.error(i).message();
		NSC_LOG_ERROR_STD(_T("Error: ") + utf8::cvt<std::wstring>(message.error(i).message()));
	}
	return ret;
}
Example #2
0
int NSCPClient::clp_handler_impl::send(connection_data &con, ::NSCPIPC::Common_MessageTypes type, const std::string &request_message, std::string &response_message) {
	NSCPIPC::PayloadMessage request_payload;
	nscp::packet request_packet;
	request_payload.set_type(type);
	request_payload.set_message(request_message);
	request_packet.add_payload(request_payload.SerializeAsString());

	nscp::packet response_packet = send(con, request_packet);
	NSCPIPC::PayloadMessage response_payload;
	std::string tmp;
	if (response_packet.get_error(tmp)) {
		NSCPIPC::ErrorMessage error;
		error.ParseFromString(tmp);
		for (int i=0;i<error.error_size();i++)
			NSC_LOG_ERROR("Invalid response: " + error.error(i).message());
		return NSCAPI::hasFailed;
	} else if (response_packet.get_payload(tmp)) {
		response_payload.ParseFromString(tmp);
		response_message = response_payload.message();
	} else {
		NSC_LOG_ERROR("Invalid response");
		return NSCAPI::hasFailed;
	}
	return NSCAPI::isSuccess;
}