1
This commit is contained in:
parent
8316eb4743
commit
8b61a75d6f
@ -105,38 +105,47 @@ void Guild::Deserialize(const std::string& guild_data, const std::string& guild_
|
||||
GenSortedMembers();
|
||||
}
|
||||
|
||||
void Guild::_CMGuildInfo(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildInfo& msg)
|
||||
void Guild::_CMGuildInfo(f8::MsgHdr& hdr, const cs::CMGuildInfo& msg)
|
||||
{
|
||||
cs::SMGuildInfo respmsg;
|
||||
FillGuildBasic(respmsg.mutable_info());
|
||||
#if 0
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(socket_handle, context, respmsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Guild::_CMGuildJoin(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildJoin& msg)
|
||||
void Guild::_CMGuildJoin(f8::MsgHdr& hdr, const cs::CMGuildJoin& msg)
|
||||
{
|
||||
cs::SMGuildJoin respmsg;
|
||||
#if 0
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(socket_handle, context, respmsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Guild::_CMGuildAgree(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildAgree& msg)
|
||||
void Guild::_CMGuildAgree(f8::MsgHdr& hdr, const cs::CMGuildAgree& msg)
|
||||
{
|
||||
cs::SMGuildAgree respmsg;
|
||||
#if 0
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(socket_handle, context, respmsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Guild::_CMGuildKick(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildKick& msg)
|
||||
void Guild::_CMGuildKick(f8::MsgHdr& hdr, const cs::CMGuildKick& msg)
|
||||
{
|
||||
cs::SMGuildKick respmsg;
|
||||
#if 0
|
||||
GuildMember* member = GetMember(context.user_info().base_data().account_id());
|
||||
if (!member) {
|
||||
return;
|
||||
}
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(socket_handle, context, respmsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Guild::_CMGuildQuit(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildQuit& msg)
|
||||
void Guild::_CMGuildQuit(f8::MsgHdr& hdr, const cs::CMGuildQuit& msg)
|
||||
{
|
||||
cs::SMGuildQuit respmsg;
|
||||
#if 0
|
||||
GuildMember* member = GetMember(context.user_info().base_data().account_id());
|
||||
if (!member) {
|
||||
return;
|
||||
@ -146,11 +155,13 @@ void Guild::_CMGuildQuit(int socket_handle, const ss::MFIMMsgConext& context, co
|
||||
}
|
||||
RemoveMember(member->account_id);
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(socket_handle, context, respmsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Guild::_CMGuildDismiss(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildDismiss& msg)
|
||||
void Guild::_CMGuildDismiss(f8::MsgHdr& hdr, const cs::CMGuildDismiss& msg)
|
||||
{
|
||||
cs::SMGuildDismiss respmsg;
|
||||
#if 0
|
||||
GuildMember* member = GetMember(context.user_info().base_data().account_id());
|
||||
if (!member) {
|
||||
return;
|
||||
@ -161,17 +172,20 @@ void Guild::_CMGuildDismiss(int socket_handle, const ss::MFIMMsgConext& context,
|
||||
guild_status = kGuildDismissed;
|
||||
SaveToDB();
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(socket_handle, context, respmsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Guild::_CMGuildRename(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildRename& msg)
|
||||
void Guild::_CMGuildRename(f8::MsgHdr& hdr, const cs::CMGuildRename& msg)
|
||||
{
|
||||
guild_name = msg.new_name();
|
||||
cs::SMGuildRename respmsg;
|
||||
#if 0
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(socket_handle, context, respmsg);
|
||||
MarkDirty();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Guild::_CMGuildMemberList(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildMemberList& msg)
|
||||
void Guild::_CMGuildMemberList(f8::MsgHdr& hdr, const cs::CMGuildMemberList& msg)
|
||||
{
|
||||
cs::SMGuildMemberList respmsg;
|
||||
*respmsg.mutable_paging() = msg.paging();
|
||||
@ -188,10 +202,12 @@ void Guild::_CMGuildMemberList(int socket_handle, const ss::MFIMMsgConext& conte
|
||||
auto p = respmsg.add_member_list();
|
||||
TypeConvert::Convert(*sorted_members_[i], *p);
|
||||
}
|
||||
#if 0
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(socket_handle, context, respmsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Guild::_CMGuildLog(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildLog& msg)
|
||||
void Guild::_CMGuildLog(f8::MsgHdr& hdr, const cs::CMGuildLog& msg)
|
||||
{
|
||||
cs::SMGuildLog respmsg;
|
||||
*respmsg.mutable_paging() = msg.paging();
|
||||
@ -210,7 +226,9 @@ void Guild::_CMGuildLog(int socket_handle, const ss::MFIMMsgConext& context, con
|
||||
TypeConvert::Convert(*sorted_members_[i], *p);
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(socket_handle, context, respmsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Guild::FillGuildBasic(cs::MFGuildBasic* guild_basic)
|
||||
|
@ -55,15 +55,15 @@ class Guild
|
||||
void MarkDirty();
|
||||
void Deserialize(const std::string& guild_data, const std::string& guild_log);
|
||||
|
||||
void _CMGuildInfo(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildInfo& msg);
|
||||
void _CMGuildJoin(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildJoin& msg);
|
||||
void _CMGuildAgree(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildAgree& msg);
|
||||
void _CMGuildKick(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildKick& msg);
|
||||
void _CMGuildQuit(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildQuit& msg);
|
||||
void _CMGuildDismiss(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildDismiss& msg);
|
||||
void _CMGuildRename(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildRename& msg);
|
||||
void _CMGuildMemberList(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildMemberList& msg);
|
||||
void _CMGuildLog(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildLog& msg);
|
||||
void _CMGuildInfo(f8::MsgHdr& hdr, const cs::CMGuildInfo& msg);
|
||||
void _CMGuildJoin(f8::MsgHdr& hdr, const cs::CMGuildJoin& msg);
|
||||
void _CMGuildAgree(f8::MsgHdr& hdr, const cs::CMGuildAgree& msg);
|
||||
void _CMGuildKick(f8::MsgHdr& hdr, const cs::CMGuildKick& msg);
|
||||
void _CMGuildQuit(f8::MsgHdr& hdr, const cs::CMGuildQuit& msg);
|
||||
void _CMGuildDismiss(f8::MsgHdr& hdr, const cs::CMGuildDismiss& msg);
|
||||
void _CMGuildRename(f8::MsgHdr& hdr, const cs::CMGuildRename& msg);
|
||||
void _CMGuildMemberList(f8::MsgHdr& hdr, const cs::CMGuildMemberList& msg);
|
||||
void _CMGuildLog(f8::MsgHdr& hdr, const cs::CMGuildLog& msg);
|
||||
|
||||
private:
|
||||
bool IsFull();
|
||||
|
@ -27,115 +27,15 @@ public:
|
||||
time_t time = 0;
|
||||
ss::SS_IM_ForwardGuildCMMsg forward_msg;
|
||||
|
||||
virtual ~AsyncGuildTask() {}
|
||||
virtual void Execute(Guild* guild) {}
|
||||
virtual void OnError() {}
|
||||
};
|
||||
|
||||
class CMGuildInfoTask : public AsyncGuildTask
|
||||
{
|
||||
private:
|
||||
cs::CMGuildInfo cmmsg;
|
||||
|
||||
virtual void Execute(Guild* guild) override
|
||||
void Execute(Guild* guild)
|
||||
{
|
||||
guild->_CMGuildInfo(socket_handle, forward_msg.context(), cmmsg);
|
||||
}
|
||||
};
|
||||
|
||||
class CMGuildJoinTask : public AsyncGuildTask
|
||||
{
|
||||
private:
|
||||
cs::CMGuildJoin cmmsg;
|
||||
|
||||
virtual void Execute(Guild* guild) override
|
||||
{
|
||||
guild->_CMGuildJoin(socket_handle, forward_msg.context(), cmmsg);
|
||||
}
|
||||
};
|
||||
|
||||
class CMGuildAgreeTask : public AsyncGuildTask
|
||||
{
|
||||
private:
|
||||
cs::CMGuildAgree cmmsg;
|
||||
|
||||
virtual void Execute(Guild* guild) override
|
||||
{
|
||||
guild->_CMGuildAgree(socket_handle, forward_msg.context(), cmmsg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CMGuildKickTask : public AsyncGuildTask
|
||||
{
|
||||
private:
|
||||
cs::CMGuildKick cmmsg;
|
||||
|
||||
virtual void Execute(Guild* guild) override
|
||||
void OnError()
|
||||
{
|
||||
guild->_CMGuildKick(socket_handle, forward_msg.context(), cmmsg);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CMGuildQuitTask : public AsyncGuildTask
|
||||
{
|
||||
private:
|
||||
cs::CMGuildQuit cmmsg;
|
||||
|
||||
virtual void Execute(Guild* guild) override
|
||||
{
|
||||
guild->_CMGuildQuit(socket_handle, forward_msg.context(), cmmsg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CMGuildDismissTask : public AsyncGuildTask
|
||||
{
|
||||
private:
|
||||
cs::CMGuildDismiss cmmsg;
|
||||
|
||||
virtual void Execute(Guild* guild) override
|
||||
{
|
||||
guild->_CMGuildDismiss(socket_handle, forward_msg.context(), cmmsg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CMGuildRenameTask : public AsyncGuildTask
|
||||
{
|
||||
private:
|
||||
cs::CMGuildRename cmmsg;
|
||||
|
||||
virtual void Execute(Guild* guild) override
|
||||
{
|
||||
guild->_CMGuildRename(socket_handle, forward_msg.context(), cmmsg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CMGuildMemberListTask : public AsyncGuildTask
|
||||
{
|
||||
private:
|
||||
cs::CMGuildMemberList cmmsg;
|
||||
|
||||
virtual void Execute(Guild* guild) override
|
||||
{
|
||||
guild->_CMGuildMemberList(socket_handle, forward_msg.context(), cmmsg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CMGuildLogTask : public AsyncGuildTask
|
||||
{
|
||||
private:
|
||||
cs::CMGuildLog cmmsg;
|
||||
|
||||
virtual void Execute(Guild* guild) override
|
||||
{
|
||||
guild->_CMGuildLog(socket_handle, forward_msg.context(), cmmsg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void GuildMgr::Init()
|
||||
@ -154,77 +54,13 @@ void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_Forward
|
||||
msg.msgid() > cs::CMMessageId_e::_CMGuildMsgEnd) {
|
||||
return;
|
||||
}
|
||||
if (!IsValidGuildId(msg.context().user_info().base_data().guild_id())) {
|
||||
if (!IsValidGuildId(msg.guild_id())) {
|
||||
ss::SS_CommonError respmsg;
|
||||
respmsg.set_errcode(SERVER_INTERNAL_ERROR);
|
||||
respmsg.set_errmsg("服务器内部错误");
|
||||
ForwardGuildSMMsg(hdr.socket_handle, msg.context(), msg.msgid(), respmsg);
|
||||
return;
|
||||
}
|
||||
switch (msg.msgid()) {
|
||||
case cs::CMMessageId_e::_CMGuildInfo:
|
||||
{
|
||||
cs::CMGuildInfo cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
CMGuildInfoTask* task = new CMGuildInfoTask;
|
||||
CreateAsyncTask(hdr.socket_handle, cmmsg.guild_id(), task);
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildJoin:
|
||||
{
|
||||
cs::CMGuildJoin cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
CMGuildJoinTask* task = new CMGuildJoinTask;
|
||||
CreateAsyncTask(hdr.socket_handle, cmmsg.guild_id(), task);
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildAgree:
|
||||
{
|
||||
cs::CMGuildAgree cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildKick:
|
||||
{
|
||||
cs::CMGuildKick cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildQuit:
|
||||
{
|
||||
cs::CMGuildQuit cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildDismiss:
|
||||
{
|
||||
cs::CMGuildDismiss cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildRename:
|
||||
{
|
||||
cs::CMGuildRename cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildMemberList:
|
||||
{
|
||||
cs::CMGuildMemberList cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildLog:
|
||||
{
|
||||
cs::CMGuildLog cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GuildMgr::CreateAsyncTask(int socket_handle, long long guild_id, AsyncGuildTask* task)
|
||||
@ -326,7 +162,7 @@ void GuildMgr::LoadGuild(long long guild_id)
|
||||
|
||||
bool GuildMgr::IsValidGuildId(long long guild_id)
|
||||
{
|
||||
return true;
|
||||
return JsonDataMgr::Instance()->GetIMInstanceId(guild_id) == App::Instance()->instance_id;
|
||||
}
|
||||
|
||||
Guild* GuildMgr::GetGuild(long long guild_id)
|
||||
|
@ -12,7 +12,6 @@ class GuildMgr : public a8::Singleton<GuildMgr>
|
||||
{
|
||||
public:
|
||||
enum { HID = HID_GuildMgr };
|
||||
|
||||
private:
|
||||
GuildMgr() {};
|
||||
friend class a8::Singleton<GuildMgr>;
|
||||
@ -32,7 +31,6 @@ class GuildMgr : public a8::Singleton<GuildMgr>
|
||||
int msgid,
|
||||
const ::google::protobuf::Message& smmsg);
|
||||
void _SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg);
|
||||
|
||||
private:
|
||||
void CreateAsyncTask(int socket_handle, long long guild_id, AsyncGuildTask* task);
|
||||
void LoadGuild(long long guild_id);
|
||||
@ -59,7 +57,6 @@ class GuildMgr : public a8::Singleton<GuildMgr>
|
||||
int guild_status,
|
||||
int createtime
|
||||
);
|
||||
|
||||
private:
|
||||
std::map<long long, Guild*> id_hash_;
|
||||
std::set<long long> pending_guild_hash_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user