This commit is contained in:
aozhiwei 2024-07-31 10:04:57 +08:00
parent 1e328fb0da
commit 4f415520b6
2 changed files with 12 additions and 4 deletions

View File

@ -86,15 +86,17 @@ void BoxDrop::RequestAllocBoxNum()
url_params->SetVal("room_uuid", room_->GetRoomUuid());
url_params->SetVal("account_id", account_id);
url_params->SetVal("session_id", session_id);
std::string room_uuid = room_->GetRoomUuid();
HttpProxy::Instance()->HttpGet
(
[room_wp = room_->weak_from_this()]
[room_wp = room_->weak_from_this(), room_uuid]
(bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
{
if (ok) {
f8::UdpLog::Instance()->Info
("RequestAllocBoxNum ok %s",
("RequestAllocBoxNum ok room_uuid:%s %s",
{
room_uuid,
rsp_obj->ToJsonStr()
});
if (rsp_obj->GetType() != a8::XOT_OBJECT ||
@ -112,9 +114,9 @@ void BoxDrop::RequestAllocBoxNum()
}
} else {
f8::UdpLog::Instance()->Warning
("RequestAllocBoxNum error %s",
("RequestAllocBoxNum error room_uuid:%s",
{
""
room_uuid
});
}
},
@ -203,6 +205,11 @@ void BoxDrop::OnAllocOk(int box_num)
if (!get_box_num_timer_.expired()) {
room_->xtimer.Delete(get_box_num_timer_);
}
if (alloced_) {
return;
}
alloced_ = true;
alloc_box_num_ = box_num;
}
void BoxDrop::OnAllocFail()

View File

@ -30,5 +30,6 @@ class BoxDrop : public std::enable_shared_from_this<BoxDrop>
a8::XTimerWp get_box_num_timer_;
int used_num_ = 0;
int alloc_box_num_ = 0;
bool alloced_ = false;
bool returned_ = false;
};