1
This commit is contained in:
parent
a181513c83
commit
ab6daeb874
@ -170,13 +170,6 @@ void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_Forward
|
|||||||
CreateAsyncTask(hdr.socket_handle, cmmsg.guild_id(), task);
|
CreateAsyncTask(hdr.socket_handle, cmmsg.guild_id(), task);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cs::CMMessageId_e::_CMGuildCreate:
|
|
||||||
{
|
|
||||||
cs::CMGuildCreate cmmsg;
|
|
||||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
|
||||||
_CMGuildCreate(hdr.socket_handle, msg.context(), cmmsg);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case cs::CMMessageId_e::_CMGuildJoin:
|
case cs::CMMessageId_e::_CMGuildJoin:
|
||||||
{
|
{
|
||||||
cs::CMGuildJoin cmmsg;
|
cs::CMGuildJoin cmmsg;
|
||||||
@ -215,20 +208,6 @@ void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_Forward
|
|||||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cs::CMMessageId_e::_CMGuildSearch:
|
|
||||||
{
|
|
||||||
cs::CMGuildSearch cmmsg;
|
|
||||||
cmmsg.ParseFromArray(msg.payload().data(), msg.payload().size());
|
|
||||||
_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(hdr.socket_handle, msg.context(), cmmsg);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case cs::CMMessageId_e::_CMGuildMemberList:
|
case cs::CMMessageId_e::_CMGuildMemberList:
|
||||||
{
|
{
|
||||||
cs::CMGuildMemberList cmmsg;
|
cs::CMGuildMemberList cmmsg;
|
||||||
@ -248,227 +227,6 @@ void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_Forward
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuildMgr::_CMGuildCreate(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildCreate& msg)
|
|
||||||
{
|
|
||||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(socket_handle);
|
|
||||||
if (!hum) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Guild* guild = GetGuild(context.user_info().base_data().guild_id());
|
|
||||||
if (guild) {
|
|
||||||
cs::SMGuildCreate respmsg;
|
|
||||||
respmsg.set_errcode(1);
|
|
||||||
respmsg.set_errmsg("公会id已经存在");
|
|
||||||
ForwardGuildSMMsg(socket_handle, context, respmsg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::string ip;
|
|
||||||
int port = 0;
|
|
||||||
JsonDataMgr::Instance()->GetRankServerConf(ip, port);
|
|
||||||
|
|
||||||
struct MsgContext
|
|
||||||
{
|
|
||||||
int socket_handle = 0;
|
|
||||||
ss::MFIMMsgConext context;
|
|
||||||
cs::CMGuildCreate msg;
|
|
||||||
long long guild_id = 0;
|
|
||||||
};
|
|
||||||
MsgContext* msg_context = new MsgContext;
|
|
||||||
msg_context->socket_handle = socket_handle;
|
|
||||||
msg_context->context = context;
|
|
||||||
msg_context->msg = msg;
|
|
||||||
msg_context->guild_id = App::Instance()->NewUUID();
|
|
||||||
a8::MutableXObject* params = a8::MutableXObject::NewObject();
|
|
||||||
params->SetVal("gameid", hum->gameid);
|
|
||||||
params->SetVal("guild_id", msg_context->guild_id);
|
|
||||||
params->SetVal("guild_name", msg.guild_name());
|
|
||||||
params->SetVal("guild_badge", msg.guild_badge());
|
|
||||||
params->SetVal("guild_lv", 1);
|
|
||||||
params->SetVal("guild_exp", 0);
|
|
||||||
params->SetVal("guild_declaration", msg.guild_declaration());
|
|
||||||
params->SetVal("owner_id", hum->AccountId());
|
|
||||||
params->SetVal("owner_name", hum->NickName());
|
|
||||||
params->SetVal("owner_avatar_url", hum->AvatarUrl());
|
|
||||||
f8::HttpClientPool::Instance()->HttpGet
|
|
||||||
(
|
|
||||||
a8::XParams()
|
|
||||||
.SetSender(msg_context),
|
|
||||||
[] (a8::XParams& param, a8::XObject& data)
|
|
||||||
{
|
|
||||||
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
|
||||||
|
|
||||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
|
||||||
if (hum) {
|
|
||||||
cs::SMGuildCreate respmsg;
|
|
||||||
hum->SendMsg(respmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
A8_SAFE_DELETE(msg_context);
|
|
||||||
},
|
|
||||||
[] (a8::XParams& param, const std::string& response)
|
|
||||||
{
|
|
||||||
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
|
||||||
|
|
||||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
|
||||||
if (hum) {
|
|
||||||
cs::SMGuildCreate respmsg;
|
|
||||||
hum->SendMsg(respmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
A8_SAFE_DELETE(msg_context);
|
|
||||||
},
|
|
||||||
a8::Format("http://%s:%d/webapp/index.php?c=Guild&a=create", {ip, port}).c_str(),
|
|
||||||
*params,
|
|
||||||
msg_context->guild_id
|
|
||||||
);
|
|
||||||
delete params;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuildMgr::_CMGuildSearch(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildSearch& msg)
|
|
||||||
{
|
|
||||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(socket_handle);
|
|
||||||
if (!hum) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ip;
|
|
||||||
int port = 0;
|
|
||||||
JsonDataMgr::Instance()->GetRankServerConf(ip, port);
|
|
||||||
|
|
||||||
struct MsgContext
|
|
||||||
{
|
|
||||||
int socket_handle = 0;
|
|
||||||
ss::MFIMMsgConext context;
|
|
||||||
cs::CMGuildSearch msg;
|
|
||||||
};
|
|
||||||
MsgContext* msg_context = new MsgContext;
|
|
||||||
msg_context->socket_handle = socket_handle;
|
|
||||||
msg_context->context = context;
|
|
||||||
msg_context->msg = msg;
|
|
||||||
|
|
||||||
a8::MutableXObject* params = a8::MutableXObject::NewObject();
|
|
||||||
params->SetVal("gameid", hum->gameid);
|
|
||||||
params->SetVal("guild_name", msg.guild_name());
|
|
||||||
params->SetVal("curr_page", msg.paging().curr_page());
|
|
||||||
params->SetVal("page_size", msg.paging().page_size());
|
|
||||||
f8::HttpClientPool::Instance()->HttpGet
|
|
||||||
(
|
|
||||||
a8::XParams(),
|
|
||||||
[] (a8::XParams& param, a8::XObject& data)
|
|
||||||
{
|
|
||||||
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
|
||||||
|
|
||||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
|
||||||
if (hum) {
|
|
||||||
cs::SMGuildSearch respmsg;
|
|
||||||
respmsg.set_errcode(data.At("errcode")->AsXValue());
|
|
||||||
respmsg.set_errmsg(data.At("errmsg")->AsXValue());
|
|
||||||
if (respmsg.errcode() == 0) {
|
|
||||||
TypeConvert::Convert(*data.At("paging"), respmsg.mutable_paging());
|
|
||||||
auto guild_list = data.At("guild_list");
|
|
||||||
for (int i = 0; i < guild_list->Size(); ++i) {
|
|
||||||
auto guild = guild_list->At(i);
|
|
||||||
auto guild_pb = respmsg.add_guild_list();
|
|
||||||
TypeConvert::Convert(*guild, guild_pb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hum->SendMsg(respmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
A8_SAFE_DELETE(msg_context);
|
|
||||||
},
|
|
||||||
[] (a8::XParams& param, const std::string& response)
|
|
||||||
{
|
|
||||||
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
|
||||||
|
|
||||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
|
||||||
if (hum) {
|
|
||||||
cs::SMGuildSearch respmsg;
|
|
||||||
respmsg.set_errcode(1);
|
|
||||||
respmsg.set_errmsg("");
|
|
||||||
hum->SendMsg(respmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
A8_SAFE_DELETE(msg_context);
|
|
||||||
},
|
|
||||||
a8::Format("http://%s:%d/webapp/index.php?c=Guild&a=search", {ip, port}).c_str(),
|
|
||||||
*params,
|
|
||||||
rand()
|
|
||||||
);
|
|
||||||
delete params;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuildMgr::_CMGuildRank(int socket_handle, const ss::MFIMMsgConext& context, const cs::CMGuildRank& msg)
|
|
||||||
{
|
|
||||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(socket_handle);
|
|
||||||
if (!hum) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ip;
|
|
||||||
int port = 0;
|
|
||||||
JsonDataMgr::Instance()->GetRankServerConf(ip, port);
|
|
||||||
|
|
||||||
struct MsgContext
|
|
||||||
{
|
|
||||||
int socket_handle = 0;
|
|
||||||
ss::MFIMMsgConext context;
|
|
||||||
cs::CMGuildRank msg;
|
|
||||||
};
|
|
||||||
MsgContext* msg_context = new MsgContext;
|
|
||||||
msg_context->socket_handle = socket_handle;
|
|
||||||
msg_context->context = context;
|
|
||||||
msg_context->msg = msg;
|
|
||||||
|
|
||||||
a8::MutableXObject* params = a8::MutableXObject::NewObject();
|
|
||||||
params->SetVal("gameid", hum->gameid);
|
|
||||||
f8::HttpClientPool::Instance()->HttpGet
|
|
||||||
(
|
|
||||||
a8::XParams(),
|
|
||||||
[] (a8::XParams& param, a8::XObject& data)
|
|
||||||
{
|
|
||||||
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
|
||||||
|
|
||||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
|
||||||
if (hum) {
|
|
||||||
cs::SMGuildRank respmsg;
|
|
||||||
respmsg.set_errcode(data.At("errcode")->AsXValue());
|
|
||||||
respmsg.set_errmsg(data.At("errmsg")->AsXValue());
|
|
||||||
if (respmsg.errcode() == 0) {
|
|
||||||
TypeConvert::Convert(*data.At("paging"), respmsg.mutable_paging());
|
|
||||||
auto guild_list = data.At("guild_list");
|
|
||||||
for (int i = 0; i < guild_list->Size(); ++i) {
|
|
||||||
auto guild = guild_list->At(i);
|
|
||||||
auto guild_pb = respmsg.add_guild_list();
|
|
||||||
TypeConvert::Convert(*guild, guild_pb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hum->SendMsg(respmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
A8_SAFE_DELETE(msg_context);
|
|
||||||
},
|
|
||||||
[] (a8::XParams& param, const std::string& response)
|
|
||||||
{
|
|
||||||
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
|
||||||
|
|
||||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
|
||||||
if (hum) {
|
|
||||||
cs::SMGuildRank respmsg;
|
|
||||||
respmsg.set_errcode(1);
|
|
||||||
respmsg.set_errmsg("");
|
|
||||||
hum->SendMsg(respmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
A8_SAFE_DELETE(msg_context);
|
|
||||||
},
|
|
||||||
a8::Format("http://%s:%d/webapp/index.php?c=Guild&a=rank", {ip, port}).c_str(),
|
|
||||||
*params,
|
|
||||||
rand()
|
|
||||||
);
|
|
||||||
delete params;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuildMgr::CreateAsyncTask(int socket_handle, long long guild_id, AsyncGuildTask* task)
|
void GuildMgr::CreateAsyncTask(int socket_handle, long long guild_id, AsyncGuildTask* task)
|
||||||
{
|
{
|
||||||
Guild* guild = GetGuild(guild_id);
|
Guild* guild = GetGuild(guild_id);
|
||||||
|
@ -41,10 +41,6 @@ class GuildMgr : public a8::Singleton<GuildMgr>
|
|||||||
void _SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg);
|
void _SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
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 CreateAsyncTask(int socket_handle, long long guild_id, AsyncGuildTask* task);
|
void CreateAsyncTask(int socket_handle, long long guild_id, AsyncGuildTask* task);
|
||||||
void LoadGuild(long long guild_id);
|
void LoadGuild(long long guild_id);
|
||||||
bool IsValidGuildId(long long guild_id);
|
bool IsValidGuildId(long long guild_id);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <a8/openssl.h>
|
#include <a8/openssl.h>
|
||||||
#include <a8/timer.h>
|
#include <a8/timer.h>
|
||||||
|
#include <a8/mutable_xobject.h>
|
||||||
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "playermgr.h"
|
#include "playermgr.h"
|
||||||
@ -26,6 +27,8 @@
|
|||||||
#include "handlermgr.h"
|
#include "handlermgr.h"
|
||||||
#include "jsondatamgr.h"
|
#include "jsondatamgr.h"
|
||||||
|
|
||||||
|
#include "framework/cpp/httpclientpool.h"
|
||||||
|
|
||||||
void Player::Init()
|
void Player::Init()
|
||||||
{
|
{
|
||||||
myself.hum = this;
|
myself.hum = this;
|
||||||
@ -625,7 +628,73 @@ void Player::_CMGuildInfo(f8::MsgHdr& hdr, const cs::CMGuildInfo& msg)
|
|||||||
|
|
||||||
void Player::_CMGuildCreate(f8::MsgHdr& hdr, const cs::CMGuildCreate& msg)
|
void Player::_CMGuildCreate(f8::MsgHdr& hdr, const cs::CMGuildCreate& msg)
|
||||||
{
|
{
|
||||||
|
cs::SMGuildCreate respmsg;
|
||||||
|
if (GuildId() != 0) {
|
||||||
|
respmsg.set_errcode(1);
|
||||||
|
respmsg.set_errmsg("你已经有公会");
|
||||||
|
SendMsg(respmsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::string ip;
|
||||||
|
int port = 0;
|
||||||
|
JsonDataMgr::Instance()->GetRankServerConf(ip, port);
|
||||||
|
|
||||||
|
struct MsgContext
|
||||||
|
{
|
||||||
|
int socket_handle = 0;
|
||||||
|
std::string account_id;
|
||||||
|
cs::CMGuildCreate msg;
|
||||||
|
long long guild_id = 0;
|
||||||
|
};
|
||||||
|
MsgContext* msg_context = new MsgContext;
|
||||||
|
msg_context->socket_handle = socket_handle;
|
||||||
|
msg_context->account_id = AccountId();
|
||||||
|
msg_context->msg = msg;
|
||||||
|
msg_context->guild_id = App::Instance()->NewUUID();
|
||||||
|
a8::MutableXObject* params = a8::MutableXObject::NewObject();
|
||||||
|
params->SetVal("gameid", gameid);
|
||||||
|
params->SetVal("guild_id", msg_context->guild_id);
|
||||||
|
params->SetVal("guild_name", msg.guild_name());
|
||||||
|
params->SetVal("guild_badge", msg.guild_badge());
|
||||||
|
params->SetVal("guild_lv", 1);
|
||||||
|
params->SetVal("guild_exp", 0);
|
||||||
|
params->SetVal("guild_declaration", msg.guild_declaration());
|
||||||
|
params->SetVal("owner_id", AccountId());
|
||||||
|
params->SetVal("owner_name", NickName());
|
||||||
|
params->SetVal("owner_avatar_url", AvatarUrl());
|
||||||
|
f8::HttpClientPool::Instance()->HttpGet
|
||||||
|
(
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(msg_context),
|
||||||
|
[] (a8::XParams& param, a8::XObject& data)
|
||||||
|
{
|
||||||
|
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
||||||
|
|
||||||
|
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
||||||
|
if (hum && hum->AccountId() == msg_context->account_id) {
|
||||||
|
cs::SMGuildCreate respmsg;
|
||||||
|
hum->SendMsg(respmsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
A8_SAFE_DELETE(msg_context);
|
||||||
|
},
|
||||||
|
[] (a8::XParams& param, const std::string& response)
|
||||||
|
{
|
||||||
|
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
||||||
|
|
||||||
|
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
||||||
|
if (hum && hum->AccountId() == msg_context->account_id) {
|
||||||
|
cs::SMGuildCreate respmsg;
|
||||||
|
hum->SendMsg(respmsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
A8_SAFE_DELETE(msg_context);
|
||||||
|
},
|
||||||
|
a8::Format("http://%s:%d/webapp/index.php?c=Guild&a=create", {ip, port}).c_str(),
|
||||||
|
*params,
|
||||||
|
msg_context->guild_id
|
||||||
|
);
|
||||||
|
delete params;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMGuildJoin(f8::MsgHdr& hdr, const cs::CMGuildJoin& msg)
|
void Player::_CMGuildJoin(f8::MsgHdr& hdr, const cs::CMGuildJoin& msg)
|
||||||
@ -668,12 +737,137 @@ void Player::_CMGuildRename(f8::MsgHdr& hdr, const cs::CMGuildRename& msg)
|
|||||||
|
|
||||||
void Player::_CMGuildSearch(f8::MsgHdr& hdr, const cs::CMGuildSearch& msg)
|
void Player::_CMGuildSearch(f8::MsgHdr& hdr, const cs::CMGuildSearch& msg)
|
||||||
{
|
{
|
||||||
|
std::string ip;
|
||||||
|
int port = 0;
|
||||||
|
JsonDataMgr::Instance()->GetRankServerConf(ip, port);
|
||||||
|
|
||||||
|
struct MsgContext
|
||||||
|
{
|
||||||
|
int socket_handle = 0;
|
||||||
|
std::string account_id;
|
||||||
|
cs::CMGuildSearch msg;
|
||||||
|
};
|
||||||
|
MsgContext* msg_context = new MsgContext;
|
||||||
|
msg_context->socket_handle = socket_handle;
|
||||||
|
msg_context->account_id = AccountId();
|
||||||
|
msg_context->msg = msg;
|
||||||
|
|
||||||
|
a8::MutableXObject* params = a8::MutableXObject::NewObject();
|
||||||
|
params->SetVal("gameid", gameid);
|
||||||
|
params->SetVal("guild_name", msg.guild_name());
|
||||||
|
params->SetVal("curr_page", msg.paging().curr_page());
|
||||||
|
params->SetVal("page_size", msg.paging().page_size());
|
||||||
|
f8::HttpClientPool::Instance()->HttpGet
|
||||||
|
(
|
||||||
|
a8::XParams(),
|
||||||
|
[] (a8::XParams& param, a8::XObject& data)
|
||||||
|
{
|
||||||
|
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
||||||
|
|
||||||
|
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
||||||
|
if (hum && hum->AccountId() == msg_context->account_id) {
|
||||||
|
cs::SMGuildSearch respmsg;
|
||||||
|
respmsg.set_errcode(data.At("errcode")->AsXValue());
|
||||||
|
respmsg.set_errmsg(data.At("errmsg")->AsXValue());
|
||||||
|
if (respmsg.errcode() == 0) {
|
||||||
|
TypeConvert::Convert(*data.At("paging"), respmsg.mutable_paging());
|
||||||
|
auto guild_list = data.At("guild_list");
|
||||||
|
for (int i = 0; i < guild_list->Size(); ++i) {
|
||||||
|
auto guild = guild_list->At(i);
|
||||||
|
auto guild_pb = respmsg.add_guild_list();
|
||||||
|
TypeConvert::Convert(*guild, guild_pb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hum->SendMsg(respmsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
A8_SAFE_DELETE(msg_context);
|
||||||
|
},
|
||||||
|
[] (a8::XParams& param, const std::string& response)
|
||||||
|
{
|
||||||
|
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
||||||
|
|
||||||
|
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
||||||
|
if (hum && hum->AccountId() == msg_context->account_id) {
|
||||||
|
cs::SMGuildSearch respmsg;
|
||||||
|
respmsg.set_errcode(1);
|
||||||
|
respmsg.set_errmsg("");
|
||||||
|
hum->SendMsg(respmsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
A8_SAFE_DELETE(msg_context);
|
||||||
|
},
|
||||||
|
a8::Format("http://%s:%d/webapp/index.php?c=Guild&a=search", {ip, port}).c_str(),
|
||||||
|
*params,
|
||||||
|
rand()
|
||||||
|
);
|
||||||
|
delete params;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMGuildRank(f8::MsgHdr& hdr, const cs::CMGuildRank& msg)
|
void Player::_CMGuildRank(f8::MsgHdr& hdr, const cs::CMGuildRank& msg)
|
||||||
{
|
{
|
||||||
|
std::string ip;
|
||||||
|
int port = 0;
|
||||||
|
JsonDataMgr::Instance()->GetRankServerConf(ip, port);
|
||||||
|
|
||||||
|
struct MsgContext
|
||||||
|
{
|
||||||
|
int socket_handle = 0;
|
||||||
|
std::string account_id;
|
||||||
|
cs::CMGuildRank msg;
|
||||||
|
};
|
||||||
|
MsgContext* msg_context = new MsgContext;
|
||||||
|
msg_context->socket_handle = socket_handle;
|
||||||
|
msg_context->account_id = AccountId();
|
||||||
|
msg_context->msg = msg;
|
||||||
|
|
||||||
|
a8::MutableXObject* params = a8::MutableXObject::NewObject();
|
||||||
|
params->SetVal("gameid", gameid);
|
||||||
|
f8::HttpClientPool::Instance()->HttpGet
|
||||||
|
(
|
||||||
|
a8::XParams(),
|
||||||
|
[] (a8::XParams& param, a8::XObject& data)
|
||||||
|
{
|
||||||
|
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
||||||
|
|
||||||
|
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
||||||
|
if (hum) {
|
||||||
|
cs::SMGuildRank respmsg;
|
||||||
|
respmsg.set_errcode(data.At("errcode")->AsXValue());
|
||||||
|
respmsg.set_errmsg(data.At("errmsg")->AsXValue());
|
||||||
|
if (respmsg.errcode() == 0) {
|
||||||
|
TypeConvert::Convert(*data.At("paging"), respmsg.mutable_paging());
|
||||||
|
auto guild_list = data.At("guild_list");
|
||||||
|
for (int i = 0; i < guild_list->Size(); ++i) {
|
||||||
|
auto guild = guild_list->At(i);
|
||||||
|
auto guild_pb = respmsg.add_guild_list();
|
||||||
|
TypeConvert::Convert(*guild, guild_pb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hum->SendMsg(respmsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
A8_SAFE_DELETE(msg_context);
|
||||||
|
},
|
||||||
|
[] (a8::XParams& param, const std::string& response)
|
||||||
|
{
|
||||||
|
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
|
||||||
|
|
||||||
|
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(msg_context->socket_handle);
|
||||||
|
if (hum) {
|
||||||
|
cs::SMGuildRank respmsg;
|
||||||
|
respmsg.set_errcode(1);
|
||||||
|
respmsg.set_errmsg("");
|
||||||
|
hum->SendMsg(respmsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
A8_SAFE_DELETE(msg_context);
|
||||||
|
},
|
||||||
|
a8::Format("http://%s:%d/webapp/index.php?c=Guild&a=rank", {ip, port}).c_str(),
|
||||||
|
*params,
|
||||||
|
rand()
|
||||||
|
);
|
||||||
|
delete params;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMGuildMemberList(f8::MsgHdr& hdr, const cs::CMGuildMemberList& msg)
|
void Player::_CMGuildMemberList(f8::MsgHdr& hdr, const cs::CMGuildMemberList& msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user