本文整理汇总了C++中FSM::ProcessEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ FSM::ProcessEvent方法的具体用法?C++ FSM::ProcessEvent怎么用?C++ FSM::ProcessEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSM
的用法示例。
在下文中一共展示了FSM::ProcessEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandlePollCompleteResponse
void HandlePollCompleteResponse(
FSM & fsm,
const mf::api::upload::poll_upload::Response & response
)
{
if (response.quickkey)
{
if (response.filename)
{
// Filename was changed
fsm.ProcessEvent(event::PollComplete{
*response.quickkey,
*response.filename
});
}
else
{
fsm.ProcessEvent(event::PollComplete{
*response.quickkey,
fsm.filename()
});
}
}
else
{
fsm.ProcessEvent(event::Error{
make_error_code(api::api_code::ContentInvalidData),
"Successful response missing quickkey"
});
}
}
示例2: 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));
}
}
}
示例3: HandlePollCompleteResponse
void HandlePollCompleteResponse(
FSM & fsm,
const mf::api::upload::poll_upload::Response & response)
{
assert(response.response_data);
const auto & response_data = *response.response_data;
if (!response_data.quickkey)
{
fsm.ProcessEvent(
event::Error{make_error_code(api::api_code::ContentInvalidData),
"Successful response missing quickkey"});
}
else if (!response_data.revision)
{
fsm.ProcessEvent(
event::Error{make_error_code(api::api_code::ContentInvalidData),
"Successful response missing revision"});
}
else
{
if (response_data.filename)
{
// Filename was changed
fsm.ProcessEvent(event::PollComplete{*response_data.quickkey,
*response_data.filename,
*response_data.revision});
}
else
{
fsm.ProcessEvent(event::PollComplete{*response_data.quickkey,
fsm.filename(),
*response_data.revision});
}
}
}
示例4: 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);
});
}