1
This commit is contained in:
parent
a97e7b5092
commit
516d58263c
@ -13,6 +13,8 @@
|
|||||||
#include "synchelper.h"
|
#include "synchelper.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
|
#include "framework/cpp/httpclientpool.h"
|
||||||
|
|
||||||
const int GUILD_MAX_MEMBER_NUM = 50;
|
const int GUILD_MAX_MEMBER_NUM = 50;
|
||||||
|
|
||||||
enum GuildApplyStatus_e
|
enum GuildApplyStatus_e
|
||||||
@ -121,6 +123,64 @@ void Guild::MarkDirty()
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
SyncData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Guild::SyncData()
|
||||||
|
{
|
||||||
|
if (!sync_timer_) {
|
||||||
|
sync_timer_ = a8::Timer::Instance()->AddDeadLineTimerAndAttach
|
||||||
|
(1000 * 3,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender((void*)this),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Guild* guild = (Guild*)param.sender.GetUserData();
|
||||||
|
guild->SendUpdate();
|
||||||
|
},
|
||||||
|
&timer_attacher_.timer_list_,
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Guild* guild = (Guild*)param.sender.GetUserData();
|
||||||
|
guild->sync_timer_ = nullptr;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Guild::SendUpdate()
|
||||||
|
{
|
||||||
|
std::string ip;
|
||||||
|
int port = 0;
|
||||||
|
JsonDataMgr::Instance()->GetRankServerConf(ip, port);
|
||||||
|
|
||||||
|
a8::MutableXObject* params = a8::MutableXObject::NewObject();
|
||||||
|
params->SetVal("guild_id", guild_id_);
|
||||||
|
params->SetVal("guild_name", guild_name_);
|
||||||
|
params->SetVal("guild_badge", guild_badge_);
|
||||||
|
params->SetVal("guild_lv", guild_lv_);
|
||||||
|
params->SetVal("guild_exp", guild_exp_);
|
||||||
|
params->SetVal("guild_declaration", guild_declaration_);
|
||||||
|
params->SetVal("owner_id", owner_id_);
|
||||||
|
params->SetVal("owner_name", owner_name_);
|
||||||
|
params->SetVal("owner_avatar_url", owner_avatar_url_);
|
||||||
|
params->SetVal("join_unlimited", join_unlimited_);
|
||||||
|
params->SetVal("join_cond1", join_cond1_);
|
||||||
|
params->SetVal("join_cond2", join_cond2_);
|
||||||
|
f8::HttpClientPool::Instance()->HttpGet
|
||||||
|
(
|
||||||
|
a8::XParams(),
|
||||||
|
[] (a8::XParams& param, a8::XObject& data)
|
||||||
|
{
|
||||||
|
},
|
||||||
|
[] (a8::XParams& param, const std::string& response)
|
||||||
|
{
|
||||||
|
},
|
||||||
|
a8::Format("http://%s:%d/webapp/index.php?c=Guild&a=update", {ip, port}).c_str(),
|
||||||
|
*params,
|
||||||
|
GuildId()
|
||||||
|
);
|
||||||
|
delete params;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Guild::Deserialize(const std::string& guild_data,
|
void Guild::Deserialize(const std::string& guild_data,
|
||||||
|
@ -42,6 +42,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool IsFull();
|
bool IsFull();
|
||||||
void MarkDirty();
|
void MarkDirty();
|
||||||
|
void SyncData();
|
||||||
|
void SendUpdate();
|
||||||
GuildMember* GetMember(const std::string& account_id);
|
GuildMember* GetMember(const std::string& account_id);
|
||||||
void AddMember(GuildMember* member);
|
void AddMember(GuildMember* member);
|
||||||
void RemoveMember(const std::string& sender_id,
|
void RemoveMember(const std::string& sender_id,
|
||||||
@ -68,6 +70,7 @@ private:
|
|||||||
bool dirty_ = false;
|
bool dirty_ = false;
|
||||||
long long last_apply_idx_ = 0;
|
long long last_apply_idx_ = 0;
|
||||||
timer_list* dirty_timer_ = nullptr;
|
timer_list* dirty_timer_ = nullptr;
|
||||||
|
timer_list* sync_timer_ = nullptr;
|
||||||
std::map<std::string, GuildMember*> member_hash_;
|
std::map<std::string, GuildMember*> member_hash_;
|
||||||
std::vector<GuildMember*> sorted_members_;
|
std::vector<GuildMember*> sorted_members_;
|
||||||
ss::MFGuildLogDB* logdb_ = nullptr;
|
ss::MFGuildLogDB* logdb_ = nullptr;
|
||||||
|
@ -175,7 +175,28 @@ void GuildMgr::__GuildSearch(f8::JsonHttpRequest* request)
|
|||||||
|
|
||||||
void GuildMgr::__GuildUpdate(f8::JsonHttpRequest* request)
|
void GuildMgr::__GuildUpdate(f8::JsonHttpRequest* request)
|
||||||
{
|
{
|
||||||
|
if (!load_done_) {
|
||||||
|
request->resp_xobj->SetVal("errcode", 2);
|
||||||
|
request->resp_xobj->SetVal("errmsg", "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long long guild_id = request->request.At("guild_id")->AsXValue();
|
||||||
|
cs::MFGuildBasic* guild = GetGuild(guild_id);
|
||||||
|
if (guild) {
|
||||||
|
guild->set_guild_name(request->request.At("guild_name")->AsXValue());
|
||||||
|
guild->set_guild_badge(request->request.At("guild_badge")->AsXValue());
|
||||||
|
guild->set_guild_lv(request->request.At("guild_lv")->AsXValue());
|
||||||
|
guild->set_guild_exp(request->request.At("guild_exp")->AsXValue());
|
||||||
|
guild->set_guild_declaration(request->request.At("guild_declaration")->AsXValue());
|
||||||
|
guild->set_owner_id(request->request.At("owner_id")->AsXValue());
|
||||||
|
guild->set_owner_name(request->request.At("owner_name")->AsXValue());
|
||||||
|
guild->set_owner_avatar_url(request->request.At("owner_avatar_url")->AsXValue());
|
||||||
|
guild->set_join_unlimited(request->request.At("join_unlimited")->AsXValue());
|
||||||
|
guild->set_join_cond1(request->request.At("join_cond1")->AsXValue());
|
||||||
|
guild->set_join_cond2(request->request.At("join_cond2")->AsXValue());
|
||||||
|
}
|
||||||
|
request->resp_xobj->SetVal("errcode", 0);
|
||||||
|
request->resp_xobj->SetVal("errmsg", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuildMgr::__GuildRank(f8::JsonHttpRequest* request)
|
void GuildMgr::__GuildRank(f8::JsonHttpRequest* request)
|
||||||
@ -532,8 +553,8 @@ void GuildMgr::UpdateGuild(cs::MFGuildBasic* new_guild)
|
|||||||
guild->set_owner_name((new_guild->owner_name()));
|
guild->set_owner_name((new_guild->owner_name()));
|
||||||
guild->set_owner_avatar_url((new_guild->owner_avatar_url()));
|
guild->set_owner_avatar_url((new_guild->owner_avatar_url()));
|
||||||
guild->set_join_unlimited((new_guild->join_unlimited()));
|
guild->set_join_unlimited((new_guild->join_unlimited()));
|
||||||
guild->set_join_cnod1((new_guild->join_cnod1()));
|
guild->set_join_cond1((new_guild->join_cond1()));
|
||||||
guild->set_join_cnod2((new_guild->join_cnod2()));
|
guild->set_join_cond2((new_guild->join_cond2()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user