1
This commit is contained in:
parent
664807d95a
commit
a181513c83
@ -27,12 +27,12 @@ class IMConn
|
|||||||
bool Connected();
|
bool Connected();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SendMsg(T& msg)
|
void SendMsg(const T& msg)
|
||||||
{
|
{
|
||||||
static int msgid = f8::Net_GetMessageId(msg);
|
static int msgid = f8::Net_GetMessageId(msg);
|
||||||
SendMsg(msgid, msg);
|
SendMsg(msgid, msg);
|
||||||
}
|
}
|
||||||
void SendMsg(int msgid, ::google::protobuf::Message& msg)
|
void SendMsg(int msgid, const ::google::protobuf::Message& msg)
|
||||||
{
|
{
|
||||||
f8::Net_SendMsg(tcp_client_, 0, msgid, msg);
|
f8::Net_SendMsg(tcp_client_, 0, msgid, msg);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -82,3 +82,8 @@ bool JsonDataMgr::GetRankServerConf(std::string& ip, int& port)
|
|||||||
port = conf->At("rankserver_ip")->AsXValue();
|
port = conf->At("rankserver_ip")->AsXValue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int JsonDataMgr::GetIMInstanceId(long long id)
|
||||||
|
{
|
||||||
|
return (id % imserver_cluster_json_.Size()) + 1;
|
||||||
|
}
|
||||||
|
@ -15,6 +15,7 @@ class JsonDataMgr : public a8::Singleton<JsonDataMgr>
|
|||||||
std::shared_ptr<a8::XObject> GetRankServerClusterConf();
|
std::shared_ptr<a8::XObject> GetRankServerClusterConf();
|
||||||
std::shared_ptr<a8::XObject> GetMysqlClusterConf();
|
std::shared_ptr<a8::XObject> GetMysqlClusterConf();
|
||||||
bool GetRankServerConf(std::string& ip, int& port);
|
bool GetRankServerConf(std::string& ip, int& port);
|
||||||
|
int GetIMInstanceId(long long id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string work_path_ = "../config";
|
std::string work_path_ = "../config";
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "MSConn.h"
|
#include "MSConn.h"
|
||||||
#include "MSConnMgr.h"
|
#include "MSConnMgr.h"
|
||||||
#include "handlermgr.h"
|
#include "handlermgr.h"
|
||||||
|
#include "jsondatamgr.h"
|
||||||
|
|
||||||
void Player::Init()
|
void Player::Init()
|
||||||
{
|
{
|
||||||
@ -618,6 +619,8 @@ void Player::_CMGuildInfo(f8::MsgHdr& hdr, const cs::CMGuildInfo& msg)
|
|||||||
SendMsg(respmsg);
|
SendMsg(respmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
SyncHelper::Instance()->SendIMConnMsg(JsonDataMgr::Instance()->GetIMInstanceId(msg.guild_id()),
|
||||||
|
msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMGuildCreate(f8::MsgHdr& hdr, const cs::CMGuildCreate& msg)
|
void Player::_CMGuildCreate(f8::MsgHdr& hdr, const cs::CMGuildCreate& msg)
|
||||||
@ -627,7 +630,15 @@ void Player::_CMGuildCreate(f8::MsgHdr& hdr, const cs::CMGuildCreate& msg)
|
|||||||
|
|
||||||
void Player::_CMGuildJoin(f8::MsgHdr& hdr, const cs::CMGuildJoin& msg)
|
void Player::_CMGuildJoin(f8::MsgHdr& hdr, const cs::CMGuildJoin& msg)
|
||||||
{
|
{
|
||||||
|
cs::SMGuildJoin respmsg;
|
||||||
|
if (msg.guild_id() == 0 && GuildId() == 0) {
|
||||||
|
respmsg.set_errcode(1);
|
||||||
|
respmsg.set_errmsg("你已经有公会");
|
||||||
|
SendMsg(respmsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SyncHelper::Instance()->SendIMConnMsg(JsonDataMgr::Instance()->GetIMInstanceId(msg.guild_id()),
|
||||||
|
msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMGuildAgree(f8::MsgHdr& hdr, const cs::CMGuildAgree& msg)
|
void Player::_CMGuildAgree(f8::MsgHdr& hdr, const cs::CMGuildAgree& msg)
|
||||||
|
@ -175,7 +175,7 @@ void SyncHelper::SS_IM_FriendDeleteRequest_TimeOut(ss::SS_IM_FriendDeleteRequest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyncHelper::SendIMConnMsg(int instance_id, int msgid, ::google::protobuf::Message& msg)
|
void SyncHelper::SendIMConnMsg(int instance_id, int msgid, const ::google::protobuf::Message& msg)
|
||||||
{
|
{
|
||||||
if (instance_id == App::Instance()->instance_id) {
|
if (instance_id == App::Instance()->instance_id) {
|
||||||
int packlen = msg.ByteSize();
|
int packlen = msg.ByteSize();
|
||||||
|
@ -48,13 +48,13 @@ public:
|
|||||||
void BroadcastIMConnMsg(int msgid, ::google::protobuf::Message& msg);
|
void BroadcastIMConnMsg(int msgid, ::google::protobuf::Message& msg);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SendIMConnMsg(int intance_id, T& msg)
|
void SendIMConnMsg(int intance_id, const T& msg)
|
||||||
{
|
{
|
||||||
static int msgid = f8::Net_GetMessageId(msg);
|
static int msgid = f8::Net_GetMessageId(msg);
|
||||||
SendIMConnMsg(msgid, msg);
|
SendIMConnMsg(msgid, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendIMConnMsg(int intance_id, int msgid, ::google::protobuf::Message& msg);
|
void SendIMConnMsg(int intance_id, int msgid, const ::google::protobuf::Message& msg);
|
||||||
|
|
||||||
std::map<long long, timer_list*> pending_request_hash_;
|
std::map<long long, timer_list*> pending_request_hash_;
|
||||||
};
|
};
|
||||||
|
2
third_party/framework
vendored
2
third_party/framework
vendored
@ -1 +1 @@
|
|||||||
Subproject commit ea69b96451e7004430e99b86db1cfd3ae4d76c6b
|
Subproject commit a1c591dd5f2bad2aba07134fa6b9c2415abff318
|
Loading…
x
Reference in New Issue
Block a user