1
This commit is contained in:
parent
a0c22f7536
commit
268b19d7c2
@ -5,12 +5,13 @@
|
||||
#include "cs_msgid.pb.h"
|
||||
#include "cs_proto.pb.h"
|
||||
#include "ss_proto.pb.h"
|
||||
#include "MSConnMgr.h"
|
||||
#include "IMListener.h"
|
||||
#include "asynctaskmgr.h"
|
||||
|
||||
class AsyncGuildTask
|
||||
{
|
||||
public:
|
||||
int socket_handle = 0;
|
||||
long long watch_guild_id = 0;
|
||||
time_t time = 0;
|
||||
ss::SS_IM_ForwardGuildCMMsg forward_msg;
|
||||
@ -94,7 +95,7 @@ void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_Forward
|
||||
ss::SS_CommonError respmsg;
|
||||
respmsg.set_errcode(SERVER_INTERNAL_ERROR);
|
||||
respmsg.set_errmsg("服务器内部错误");
|
||||
ForwardGuildSMMsg(msg.context(), msg.msgid(), respmsg);
|
||||
ForwardGuildSMMsg(hdr.socket_handle, msg.context(), msg.msgid(), respmsg);
|
||||
return;
|
||||
}
|
||||
switch (msg.msgid()) {
|
||||
@ -110,7 +111,7 @@ void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_Forward
|
||||
{
|
||||
cs::CMGuildCreate cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
_CMGuildCreate(msg.context(), cmmsg);
|
||||
_CMGuildCreate(hdr.socket_handle, msg.context(), cmmsg);
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildJoin:
|
||||
@ -155,14 +156,14 @@ void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_Forward
|
||||
{
|
||||
cs::CMGuildSearch cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
_CMGuildSearch(msg.context(), cmmsg);
|
||||
_CMGuildSearch(hdr.socket_handle, msg.context(), cmmsg);
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildRank:
|
||||
{
|
||||
cs::CMGuildRank cmmsg;
|
||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||
_CMGuildRank(msg.context(), cmmsg);
|
||||
_CMGuildRank(hdr.socket_handle, msg.context(), cmmsg);
|
||||
}
|
||||
break;
|
||||
case cs::CMMessageId_e::_CMGuildMemberList:
|
||||
@ -184,25 +185,25 @@ void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_Forward
|
||||
}
|
||||
}
|
||||
|
||||
void GuildMgr::_CMGuildCreate(const ss::MFIMMsgConext& context, const cs::CMGuildCreate& msg)
|
||||
void GuildMgr::_CMGuildCreate(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildCreate& msg)
|
||||
{
|
||||
Guild* guild = GetGuild(context.user_info().base_data().guild_id());
|
||||
if (guild) {
|
||||
cs::SMGuildCreate respmsg;
|
||||
respmsg.set_errcode(1);
|
||||
respmsg.set_errmsg("群id已经存在");
|
||||
ForwardGuildSMMsg(context, respmsg);
|
||||
ForwardGuildSMMsg(socket_handle, context, respmsg);
|
||||
return;
|
||||
}
|
||||
AsyncTaskMgr::Instance()->CreateNewGuildTask(context, msg);
|
||||
}
|
||||
|
||||
void GuildMgr::_CMGuildSearch(const ss::MFIMMsgConext& context, const cs::CMGuildSearch& msg)
|
||||
void GuildMgr::_CMGuildSearch(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildSearch& msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GuildMgr::_CMGuildRank(const ss::MFIMMsgConext& context, const cs::CMGuildRank& msg)
|
||||
void GuildMgr::_CMGuildRank(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildRank& msg)
|
||||
{
|
||||
|
||||
}
|
||||
@ -246,7 +247,8 @@ Guild* GuildMgr::GetGuild(long long guild_id)
|
||||
return itr != id_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
void GuildMgr::ForwardGuildSMMsg(const ss::MFIMMsgConext& context,
|
||||
void GuildMgr::ForwardGuildSMMsg(int socket_handle,
|
||||
const ss::MFIMMsgConext& context,
|
||||
int msgid,
|
||||
const ::google::protobuf::Message& smmsg)
|
||||
{
|
||||
@ -254,5 +256,5 @@ void GuildMgr::ForwardGuildSMMsg(const ss::MFIMMsgConext& context,
|
||||
*msg.mutable_context() = context;
|
||||
msg.set_msgid(msgid);
|
||||
smmsg.SerializeToString(msg.mutable_payload());
|
||||
MSConnMgr::Instance()->SendMsg(msg, 0);
|
||||
IMListener::Instance()->SendMsg(socket_handle, msg);
|
||||
}
|
||||
|
@ -31,21 +31,22 @@ class GuildMgr : public a8::Singleton<GuildMgr>
|
||||
void _SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg);
|
||||
|
||||
private:
|
||||
void _CMGuildCreate(const ss::MFIMMsgConext& context, const cs::CMGuildCreate& msg);
|
||||
void _CMGuildSearch(const ss::MFIMMsgConext& context, const cs::CMGuildSearch& msg);
|
||||
void _CMGuildRank(const ss::MFIMMsgConext& context, const cs::CMGuildRank& msg);
|
||||
void _CMGuildCreate(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildCreate& msg);
|
||||
void _CMGuildSearch(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildSearch& msg);
|
||||
void _CMGuildRank(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildRank& msg);
|
||||
|
||||
void AddAsyncTask(long long guild_id, AsyncGuildTask* task);
|
||||
void LoadGuild(long long guild_id);
|
||||
bool IsValidGuildId(long long guild_id);
|
||||
Guild* GetGuild(long long group_id);
|
||||
template <typename T>
|
||||
void ForwardGuildSMMsg(const ss::MFIMMsgConext& context, T& smmsg)
|
||||
void ForwardGuildSMMsg(int socket_handle, const ss::MFIMMsgConext& context, T& smmsg)
|
||||
{
|
||||
static int msgid = f8::Net_GetMessageId(smmsg);
|
||||
ForwardGuildSMMsg(context, msgid, smmsg);
|
||||
ForwardGuildSMMsg(socket_handle, context, msgid, smmsg);
|
||||
}
|
||||
void ForwardGuildSMMsg(const ss::MFIMMsgConext& context,
|
||||
void ForwardGuildSMMsg(int socket_handle,
|
||||
const ss::MFIMMsgConext& context,
|
||||
int msgid,
|
||||
const ::google::protobuf::Message& smmsg);
|
||||
|
||||
|
@ -177,10 +177,7 @@ void SyncHelper::SS_IM_FriendDeleteRequest_TimeOut(ss::SS_IM_FriendDeleteRequest
|
||||
|
||||
void SyncHelper::SendIMConnMsg(int instance_id, int msgid, ::google::protobuf::Message& msg)
|
||||
{
|
||||
IMConn* conn = IMConnMgr::Instance()->GetConnByInstanceId(instance_id);
|
||||
if (conn) {
|
||||
conn->SendMsg(msgid, msg);
|
||||
} else {
|
||||
if (instance_id == App::Instance()->instance_id) {
|
||||
int packlen = msg.ByteSize();
|
||||
char* buff = nullptr;
|
||||
if (packlen > 0) {
|
||||
@ -200,5 +197,10 @@ void SyncHelper::SendIMConnMsg(int instance_id, int msgid, ::google::protobuf::M
|
||||
if (buff) {
|
||||
free(buff);
|
||||
}
|
||||
} else {
|
||||
IMConn* conn = IMConnMgr::Instance()->GetConnByInstanceId(instance_id);
|
||||
if (conn) {
|
||||
conn->SendMsg(msgid, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user