From f70f76a135e33ccf86e6a6e688afd5ea5db07cb2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 16 Sep 2020 19:37:19 +0800 Subject: [PATCH] 1 --- server/imserver/guildmgr.cc | 40 +++++++++++++++++++++++++++++++++++++ server/imserver/guildmgr.h | 1 + 2 files changed, 41 insertions(+) diff --git a/server/imserver/guildmgr.cc b/server/imserver/guildmgr.cc index f6032d6..0435885 100644 --- a/server/imserver/guildmgr.cc +++ b/server/imserver/guildmgr.cc @@ -1,5 +1,7 @@ #include "precompile.h" +#include + #include "guild.h" #include "guildmgr.h" #include "cs_msgid.pb.h" @@ -7,6 +9,7 @@ #include "ss_proto.pb.h" #include "IMListener.h" #include "asynctaskmgr.h" +#include "dbengine.h" class AsyncGuildTask { @@ -237,6 +240,17 @@ void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_Forward } } +unsigned int GuildMgr::GetGuildCrc32(long long guild_id) +{ + std::string guild_id_str = a8::XValue(guild_id).GetString(); + unsigned int crc32_code = a8::openssl::Crc32 + ( + (unsigned char*)guild_id_str.data(), + guild_id_str.size() + ); + return crc32_code; +} + void GuildMgr::_CMGuildCreate(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildCreate& msg) { Guild* guild = GetGuild(context.user_info().base_data().guild_id()); @@ -289,6 +303,32 @@ void GuildMgr::LoadGuild(long long guild_id) return; } pending_guild_hash_.insert(guild_id); + + auto on_ok = + [] (a8::XParams& param, const f8::DataSet* data_set) + { + if (data_set) { + } + }; + auto on_error = + [] (a8::XParams& param, int error_code, const std::string& error_msg) + { + + }; + + a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(GetGuildCrc32(guild_id)); + DBEngine::Instance()->ExecAsyncQuery + ( + conn_info, + "", + { + + }, + a8::XParams(), + on_ok, + on_error, + GetGuildCrc32(guild_id) + ); } bool GuildMgr::IsValidGuildId(long long guild_id) diff --git a/server/imserver/guildmgr.h b/server/imserver/guildmgr.h index ae69849..6450c12 100644 --- a/server/imserver/guildmgr.h +++ b/server/imserver/guildmgr.h @@ -39,6 +39,7 @@ class GuildMgr : public a8::Singleton int msgid, const ::google::protobuf::Message& smmsg); void _SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg); + unsigned int GetGuildCrc32(long long guild_id); private: void _CMGuildCreate(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildCreate& msg);