本文整理汇总了C++中client::Result::Success方法的典型用法代码示例。如果您正苦于以下问题:C++ Result::Success方法的具体用法?C++ Result::Success怎么用?C++ Result::Success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类client::Result
的用法示例。
在下文中一共展示了Result::Success方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleCandidatePorts
/*
* Handle the list of candidate ports
* @param response the HTTPResponse that is associated with the request.
* @param devices the possbile devices & ports
* @param error an error string.
*/
void OladHTTPServer::HandleCandidatePorts(
HTTPResponse *response,
const client::Result &result,
const vector<OlaDevice> &devices) {
if (!result.Success()) {
m_server.ServeError(response, result.Error());
return;
}
vector<OlaDevice>::const_iterator iter = devices.begin();
vector<OlaInputPort>::const_iterator input_iter;
vector<OlaOutputPort>::const_iterator output_iter;
JsonArray json;
for (; iter != devices.end(); ++iter) {
const vector<OlaInputPort> &input_ports = iter->InputPorts();
for (input_iter = input_ports.begin(); input_iter != input_ports.end();
++input_iter) {
JsonObject *obj = json.AppendObject();
PortToJson(obj, *iter, *input_iter, false);
}
const vector<OlaOutputPort> &output_ports = iter->OutputPorts();
for (output_iter = output_ports.begin();
output_iter != output_ports.end(); ++output_iter) {
JsonObject *obj = json.AppendObject();
PortToJson(obj, *iter, *output_iter, true);
}
}
response->SetNoCache();
response->SetContentType(HTTPServer::CONTENT_TYPE_PLAIN);
response->SendJson(json);
delete response;
}
示例2: HandleUniverseInfo
/*
* Handle the universe info
* @param response the HTTPResponse that is associated with the request.
* @param universe the OlaUniverse object
* @param error an error string.
*/
void OladHTTPServer::HandleUniverseInfo(HTTPResponse *response,
const client::Result &result,
const OlaUniverse &universe) {
if (!result.Success()) {
m_server.ServeError(response, result.Error());
return;
}
JsonObject *json = new JsonObject();
// fire off the device/port request now. the main server is running in a
// separate thread.
m_client.FetchDeviceInfo(
ola::OLA_PLUGIN_ALL,
NewSingleCallback(this,
&OladHTTPServer::HandlePortsForUniverse,
response,
json,
universe.Id()));
json->Add("id", universe.Id());
json->Add("name", universe.Name());
json->Add("merge_mode",
(universe.MergeMode() == OlaUniverse::MERGE_HTP ? "HTP" : "LTP"));
}
示例3: HandlePluginInfo
/*
* Handle the plugin description response.
* @param response the HTTPResponse that is associated with the request.
* @param description the plugin description.
* @param error an error string.
*/
void OladHTTPServer::HandlePluginInfo(HTTPResponse *response,
string description,
const client::Result &result,
const ola::client::PluginState &state) {
if (!result.Success()) {
m_server.ServeError(response, result.Error());
return;
}
string escaped_description = description;
Escape(&escaped_description);
JsonObject json;
json.Add("description", description);
json.Add("name", state.name);
json.Add("enabled", state.enabled);
json.Add("active", state.active);
json.Add("preferences_source", state.preferences_source);
JsonArray *plugins = json.AddArray("conflicts_with");
vector<OlaPlugin>::const_iterator iter = state.conflicting_plugins.begin();
for (; iter != state.conflicting_plugins.end(); ++iter) {
JsonObject *plugin = plugins->AppendObject();
plugin->Add("active", iter->IsActive());
plugin->Add("id", iter->Id());
plugin->Add("name", iter->Name());
}
response->SetNoCache();
response->SetContentType(HTTPServer::CONTENT_TYPE_PLAIN);
response->SendJson(json);
delete response;
}
示例4: HandlePluginList
/*
* Handle the plugin list callback
* @param response the HTTPResponse that is associated with the request.
* @param plugins a list of plugins
* @param error an error string.
*/
void OladHTTPServer::HandlePluginList(HTTPResponse *response,
const client::Result &result,
const vector<OlaPlugin> &plugins) {
if (!result.Success()) {
m_server.ServeError(response, result.Error());
return;
}
JsonObject *json = new JsonObject();
// fire off the universe request now. the main server is running in a
// separate thread.
m_client.FetchUniverseList(
NewSingleCallback(this,
&OladHTTPServer::HandleUniverseList,
response,
json));
JsonArray *plugins_json = json->AddArray("plugins");
vector<OlaPlugin>::const_iterator iter;
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
JsonObject *plugin = plugins_json->AppendObject();
plugin->Add("name", iter->Name());
plugin->Add("id", iter->Id());
}
}
示例5: HandleBoolResponse
/*
* Handle the set DMX response.
* @param response the HTTPResponse that is associated with the request.
* @param error an error string.
*/
void OladHTTPServer::HandleBoolResponse(HTTPResponse *response,
const client::Result &result) {
if (!result.Success()) {
m_server.ServeError(response, result.Error());
return;
}
response->SetContentType(HTTPServer::CONTENT_TYPE_PLAIN);
response->Append("ok");
response->Send();
delete response;
}
示例6: HandlePartialPluginInfo
/*
* Handle the plugin description response.
* @param response the HTTPResponse that is associated with the request.
* @param description the plugin description.
* @param error an error string.
*/
void OladHTTPServer::HandlePartialPluginInfo(HTTPResponse *response,
int plugin_id,
const client::Result &result,
const string &description) {
if (!result.Success()) {
m_server.ServeError(response, result.Error());
return;
}
m_client.FetchPluginState(
(ola_plugin_id) plugin_id,
NewSingleCallback(this,
&OladHTTPServer::HandlePluginInfo,
response, description));
}
示例7: HandlePortsForUniverse
void OladHTTPServer::HandlePortsForUniverse(
HTTPResponse *response,
JsonObject *json,
unsigned int universe_id,
const client::Result &result,
const vector<OlaDevice> &devices) {
if (result.Success()) {
vector<OlaDevice>::const_iterator iter = devices.begin();
vector<OlaInputPort>::const_iterator input_iter;
vector<OlaOutputPort>::const_iterator output_iter;
JsonArray *output_ports_json = json->AddArray("output_ports");
JsonArray *input_ports_json = json->AddArray("input_ports");
for (; iter != devices.end(); ++iter) {
const vector<OlaInputPort> &input_ports = iter->InputPorts();
for (input_iter = input_ports.begin(); input_iter != input_ports.end();
++input_iter) {
if (input_iter->IsActive() && input_iter->Universe() == universe_id) {
JsonObject *obj = input_ports_json->AppendObject();
PortToJson(obj, *iter, *input_iter, false);
}
}
const vector<OlaOutputPort> &output_ports = iter->OutputPorts();
for (output_iter = output_ports.begin();
output_iter != output_ports.end(); ++output_iter) {
if (output_iter->IsActive() &&
output_iter->Universe() == universe_id) {
JsonObject *obj = output_ports_json->AppendObject();
PortToJson(obj, *iter, *output_iter, true);
}
}
}
}
response->SetNoCache();
response->SetContentType(HTTPServer::CONTENT_TYPE_PLAIN);
response->SendJson(*json);
delete json;
delete response;
}
示例8: HandleUniverseList
/*
* Handle the universe list callback
* @param response the HTTPResponse that is associated with the request.
* @param plugins a list of plugins
* @param error an error string.
*/
void OladHTTPServer::HandleUniverseList(HTTPResponse *response,
JsonObject *json,
const client::Result &result,
const vector<OlaUniverse> &universes) {
if (result.Success()) {
JsonArray *universe_json = json->AddArray("universes");
vector<OlaUniverse>::const_iterator iter;
for (iter = universes.begin(); iter != universes.end(); ++iter) {
JsonObject *universe = universe_json->AppendObject();
universe->Add("id", iter->Id());
universe->Add("input_ports", iter->InputPortCount());
universe->Add("name", iter->Name());
universe->Add("output_ports", iter->OutputPortCount());
universe->Add("rdm_devices", iter->RDMDeviceCount());
}
}
response->SetNoCache();
response->SetContentType(HTTPServer::CONTENT_TYPE_PLAIN);
response->SendJson(*json);
delete response;
delete json;
}
示例9: CallbackComplete
void BaseHttpAction::CallbackComplete(const client::Result &result) {
RequestComplete(!result.Success());
}