本文整理汇总了C++中FSM::AsFrontShared方法的典型用法代码示例。如果您正苦于以下问题:C++ FSM::AsFrontShared方法的具体用法?C++ FSM::AsFrontShared怎么用?C++ FSM::AsFrontShared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSM
的用法示例。
在下文中一共展示了FSM::AsFrontShared方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandlePollResponse
void HandlePollResponse(const std::string & upload_key,
FSM & fsm,
const mf::api::upload::poll_upload::Response & response)
{
if (!response.response_data)
{
auto timer = fsm.Timer();
timer->expires_from_now(
std::chrono::seconds(poll_upload_retry_timeout_seconds));
timer->async_wait(boost::bind(&RetryPoll<FSM>, upload_key,
fsm.AsFrontShared(),
boost::asio::placeholders::error));
}
else
{
const auto & response_data = *response.response_data;
// if result is negative, it indicates a failure
if (response_data.result < 0)
{
fsm.ProcessEvent(
event::Error{std::error_code(response_data.result,
poll_result_category()),
"Poll upload bad response"});
}
else if (response_data.fileerror != 0)
{
fsm.ProcessEvent(event::Error{
std::error_code(response_data.fileerror,
poll_upload_file_error_category()),
"Poll upload file error received"});
}
else if (response_data.quickkey)
{
HandlePollCompleteResponse(fsm, response);
}
else
{
auto timer = fsm.Timer();
timer->expires_from_now(
std::chrono::seconds(poll_upload_retry_timeout_seconds));
timer->async_wait(boost::bind(&RetryPoll<FSM>, upload_key,
fsm.AsFrontShared(),
boost::asio::placeholders::error));
}
}
}
示例2: operator
void operator()(
Event const &,
FSM & fsm,
SourceState&,
TargetState&
)
{
namespace instant = mf::api::upload::instant;
auto request = instant::Request( fsm.filename(), fsm.hash(),
fsm.filesize());
switch (fsm.onDuplicateAction())
{
case OnDuplicateAction::Fail:
// This is the default, same as "skip" and doesn't need to be
// set.
break;
case OnDuplicateAction::Replace:
request.SetActionOnDuplicate(instant::ActionOnDuplicate::Replace);
break;
case OnDuplicateAction::AutoRename:
request.SetActionOnDuplicate(instant::ActionOnDuplicate::Keep);
break;
default:
assert(!"Invalid duplicate action.");
break;
}
UploadTarget target_folder = fsm.targetFolder();
boost::apply_visitor(TargetSetter(&request), target_folder);
auto fsmp = fsm.AsFrontShared();
fsm.GetSessionMaintainer()->Call(
request,
[fsmp](const instant::Response & response)
{
if (response.error_code)
{
fsmp->ProcessEvent(event::Error{response.error_code,
"Failed to instant upload file."});
}
else
{
fsmp->ProcessEvent(event::InstantSuccess{ response.quickkey,
response.filename });
}
});
}
示例3: StartPoll
void StartPoll(const std::string & upload_key, FSM & fsm)
{
if (upload_key.empty())
{
assert(!"Reached poll upload without upload key");
fsm.ProcessEvent(
event::Error{make_error_code(uploader::errc::LogicError),
"Filsize unavailable."});
return;
}
auto fsmp = fsm.AsFrontShared();
fsm.GetSessionMaintainer()->Call(
mf::api::upload::poll_upload::Request(upload_key),
[fsmp, upload_key](
const mf::api::upload::poll_upload::Response & response)
{
HandlePollResponse(upload_key, *fsmp, response);
});
}