jfjoch_viewer: Add more mask functionality
This commit is contained in:
@@ -199,3 +199,33 @@ std::vector<float> JFJochHttpReader::GetPlot_i(const std::string &plot_type, flo
|
||||
"Could not parse image buffer status");
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochHttpReader::UploadUserMask(const std::vector<uint32_t>& mask) {
|
||||
std::unique_lock ul(http_mutex);
|
||||
|
||||
if (addr.empty())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"HTTP address not set. Call ReadURL() first.");
|
||||
|
||||
if (mask.empty())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"User mask is empty.");
|
||||
|
||||
httplib::Client cli_cmd(addr);
|
||||
|
||||
const char* data_ptr = reinterpret_cast<const char*>(mask.data());
|
||||
const size_t byte_size = mask.size() * sizeof(uint32_t);
|
||||
|
||||
auto res = cli_cmd.Put("/config/user_mask",
|
||||
data_ptr,
|
||||
byte_size,
|
||||
"application/octet-stream");
|
||||
|
||||
if (!res)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Failed to connect to server to upload user mask");
|
||||
|
||||
if (res->status != httplib::StatusCode::OK_200)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Server rejected user mask upload");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user