本文整理汇总了C++中message_ptr::create_response方法的典型用法代码示例。如果您正苦于以下问题:C++ message_ptr::create_response方法的具体用法?C++ message_ptr::create_response怎么用?C++ message_ptr::create_response使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message_ptr
的用法示例。
在下文中一共展示了message_ptr::create_response方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dispatch_rpc_call
int replication_app_base::dispatch_rpc_call(int code, message_ptr& request, bool ack_client)
{
auto it = _handlers.find(code);
if (it != _handlers.end())
{
if (ack_client)
{
message_ptr response = request->create_response();
int err = 0;
marshall(response->writer(), err);
it->second(request, response);
}
else
{
message_ptr response(nullptr);
it->second(request, response);
}
}
else if (ack_client)
{
message_ptr response = request->create_response();
error_code err = ERR_HANDLER_NOT_FOUND;
marshall(response->writer(), (int)err);
rpc::reply(response);
}
return 0;
}
示例2: on_request
void meta_service::on_request(message_ptr& msg)
{
meta_request_header hdr;
unmarshall(msg, hdr);
meta_response_header rhdr;
bool is_primary = _state->get_meta_server_primary(rhdr.primary_address);
if (is_primary) is_primary = (primary_address() == rhdr.primary_address);
rhdr.err = ERR_SUCCESS;
message_ptr resp = msg->create_response();
if (!is_primary)
{
rhdr.err = ERR_TALK_TO_OTHERS;
marshall(resp, rhdr);
}
else if (hdr.rpc_tag == RPC_CM_QUERY_NODE_PARTITIONS)
{
configuration_query_by_node_request request;
configuration_query_by_node_response response;
unmarshall(msg, request);
query_configuration_by_node(request, response);
marshall(resp, rhdr);
marshall(resp, response);
}
else if (hdr.rpc_tag == RPC_CM_QUERY_PARTITION_CONFIG_BY_INDEX)
{
configuration_query_by_index_request request;
configuration_query_by_index_response response;
unmarshall(msg, request);
query_configuration_by_index(request, response);
marshall(resp, rhdr);
marshall(resp, response);
}
else if (hdr.rpc_tag == RPC_CM_UPDATE_PARTITION_CONFIGURATION)
{
update_configuration(msg, resp);
return;
}
else
{
dassert(false, "unknown rpc tag %x (%s)", hdr.rpc_tag, task_code(hdr.rpc_tag).to_string());
}
rpc::reply(resp);
}
示例3: response_client_message
void replica::response_client_message(message_ptr& request, error_code error, decree d/* = invalid_decree*/)
{
if (nullptr == request)
return;
message_ptr resp = request->create_response();
resp->writer().write(error);
dassert(error != ERR_OK, "");
dinfo("handle replication request with rpc_id = %016llx failed, err = %s",
request->header().rpc_id, error.to_string());
rpc::reply(resp);
}
示例4: on_remote_cli
void command_manager::on_remote_cli(message_ptr& request)
{
std::string cmd;
unmarshall(request->reader(), cmd);
std::vector<std::string> args;
unmarshall(request->reader(), args);
std::string result;
run_command(cmd, args, result);
auto resp = request->create_response();
marshall(resp->writer(), result);
::dsn::service::rpc::reply(resp);
}