1
This commit is contained in:
parent
cf9738c9a3
commit
53392c463c
@ -29,7 +29,7 @@ void CustomBattle::ParseResult(a8::XObject& obj)
|
||||
sign_ = obj.Get("sign").GetString();
|
||||
|
||||
auto team_list = obj.At("team_list");
|
||||
if (!team_list || team_list->IsArray()) {
|
||||
if (!team_list || !team_list->IsArray()) {
|
||||
parse_ok_ = false;
|
||||
return;
|
||||
}
|
||||
@ -42,7 +42,7 @@ void CustomBattle::ParseResult(a8::XObject& obj)
|
||||
std::string team_uuid = team_obj->Get("team_uuid").GetString();
|
||||
auto member_list = team_obj->At("members");
|
||||
if (!member_list ||
|
||||
member_list->IsArray()) {
|
||||
!member_list->IsArray()) {
|
||||
parse_ok_ = false;
|
||||
return;
|
||||
}
|
||||
@ -53,7 +53,7 @@ void CustomBattle::ParseResult(a8::XObject& obj)
|
||||
uuid_hash_[team->team_uuid_] = team;
|
||||
}
|
||||
for (int ii = 0; ii < member_list->Size(); ++ii) {
|
||||
auto member_obj = member_list->At(i);
|
||||
auto member_obj = member_list->At(ii);
|
||||
if (!member_obj || !member_obj->IsObject()) {
|
||||
parse_ok_ = false;
|
||||
return;
|
||||
|
@ -12,6 +12,7 @@ class CustomBattle
|
||||
|
||||
bool GetParseOk() { return parse_ok_; }
|
||||
Room* GetRoom() { return room_; }
|
||||
void SetRoom(Room* room) { room_ = room; }
|
||||
const std::string& GetRoomId() { return room_id_; }
|
||||
const std::string& GetRoomUuid() { return room_uuid_; }
|
||||
const std::string& GetSign() { return sign_; }
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <a8/mutable_xobject.h>
|
||||
#include <a8/openssl.h>
|
||||
|
||||
#include "roommgr.h"
|
||||
#include "room.h"
|
||||
@ -838,29 +839,37 @@ void RoomMgr::AdjustCMJoin(cs::CMJoin* msg)
|
||||
std::map<std::string, std::string> test_members;
|
||||
test_members[msg->account_id()] = msg->session_id();
|
||||
auto team = a8::MutableXObject::CreateObject();
|
||||
auto members = a8::MutableXObject::CreateArray();
|
||||
team->SetVal("team_uuid", App::Instance()->NewUuid());
|
||||
for (auto& pair : test_members) {
|
||||
auto member = a8::MutableXObject::CreateObject();
|
||||
member->SetVal("account_id", pair.first);
|
||||
member->SetVal("session_id", pair.second);
|
||||
//member->SetVal("session_id", pair.second);
|
||||
members->Push(*member.get());
|
||||
}
|
||||
team_list->Push(*team);
|
||||
team->SetVal("members", *members.get());
|
||||
team_list->Push(*team.get());
|
||||
}
|
||||
{
|
||||
std::map<std::string, std::string> test_members;
|
||||
//test_members[msg->account_id()] = msg->session_id();
|
||||
test_members[msg->account_id()] = "6513_2006_2";
|
||||
auto team = a8::MutableXObject::CreateObject();
|
||||
auto members = a8::MutableXObject::CreateArray();
|
||||
team->SetVal("team_uuid", App::Instance()->NewUuid());
|
||||
for (auto& pair : test_members) {
|
||||
auto member = a8::MutableXObject::CreateObject();
|
||||
member->SetVal("account_id", pair.first);
|
||||
member->SetVal("session_id", pair.second);
|
||||
//member->SetVal("session_id", pair.second);
|
||||
members->Push(*member.get());
|
||||
}
|
||||
team_list->Push(*team);
|
||||
team->SetVal("members", *members.get());
|
||||
team_list->Push(*team.get());
|
||||
}
|
||||
data->SetVal("team_list", *team_list);
|
||||
data->SetVal("team_list", *team_list.get());
|
||||
{
|
||||
std::string custom_data;
|
||||
std::string custom_data = a8::openssl::md5
|
||||
(data->ToJsonStr() + "520d8eAbB(8cf1^#$^&!@d833a42c820432PDAFE^^)") + "|" +
|
||||
data->ToJsonStr();
|
||||
msg->set_custom_room_payload(custom_data);
|
||||
}
|
||||
}
|
||||
@ -917,7 +926,7 @@ void RoomMgr::_CMJoinCustomBattle(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
(int errcode, const std::string errmsg, std::shared_ptr<CustomBattle> p)
|
||||
{
|
||||
auto& msg = *join_msg;
|
||||
if (!errcode) {
|
||||
if (errcode) {
|
||||
RoomMgr::Instance()->JoinErrorHandle(*join_msg, 2, socket_handle);
|
||||
return;
|
||||
}
|
||||
@ -939,6 +948,7 @@ void RoomMgr::_CMJoinCustomBattle(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
RoomMgr::Instance()->JoinErrorHandle(*join_msg, 2, socket_handle);
|
||||
return;
|
||||
}
|
||||
member->GetNetData()->join_msg = join_msg;
|
||||
if (!p->GetRoom()) {
|
||||
int game_times = 0;
|
||||
RoomType_e self_room_type = GetHumanRoomType(member->GetNetData());
|
||||
@ -954,9 +964,10 @@ void RoomMgr::_CMJoinCustomBattle(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
channel,
|
||||
msg.mapid(),
|
||||
p);
|
||||
p->SetRoom(room);
|
||||
}
|
||||
member->GetNetData()->join_msg = join_msg;
|
||||
Player* hum = p->GetRoom()->NewPlayer();
|
||||
hum->room = p->GetRoom();
|
||||
hum->proto_version = msg.proto_version();
|
||||
#if 0
|
||||
hum->hero_uniid = a8::XValue(msg.hero_uniid());
|
||||
@ -976,7 +987,6 @@ void RoomMgr::_CMJoinCustomBattle(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
if (!hum->meta) {
|
||||
hum->meta = mt::Param::s().human_meta;
|
||||
}
|
||||
hum->room = p->GetRoom();
|
||||
hum->SetBattleContext(member->GetNetData());
|
||||
hum->GetBattleContext()->Init(hum);
|
||||
{
|
||||
@ -1007,8 +1017,8 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr<cs::CMJoin> join_msg,
|
||||
cb(1, "custom battle data error", nullptr);
|
||||
return;
|
||||
}
|
||||
head = join_msg->custom_room_payload().substr(0, pos - 1);
|
||||
body = join_msg->custom_room_payload().substr(pos);
|
||||
head = join_msg->custom_room_payload().substr(0, pos);
|
||||
body = join_msg->custom_room_payload().substr(pos + 1);
|
||||
auto data = std::make_shared<a8::XObject>();
|
||||
if (!data->ReadFromJsonString(body) ||
|
||||
!data->IsObject()) {
|
||||
@ -1020,7 +1030,7 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr<cs::CMJoin> join_msg,
|
||||
cb(2, "custom battle is started", nullptr);
|
||||
return;
|
||||
}
|
||||
std::string room_uuid = data->Get("team_uuid", "").GetString();
|
||||
std::string room_uuid = data->Get("room_uuid", "").GetString();
|
||||
if (room_uuid.empty()) {
|
||||
cb(1, "custom battle data error", nullptr);
|
||||
return;
|
||||
@ -1044,6 +1054,8 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr<cs::CMJoin> join_msg,
|
||||
url += "?&c=Battle&a=getCustomBattleData";
|
||||
}
|
||||
auto url_params = a8::MutableXObject::CreateObject();
|
||||
url_params->SetVal("account_id", join_msg->account_id());
|
||||
url_params->SetVal("session_id", join_msg->session_id());
|
||||
url_params->SetVal("__POST", join_msg->custom_room_payload());
|
||||
HttpProxy::Instance()->HttpGet
|
||||
(
|
||||
@ -1063,11 +1075,11 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr<cs::CMJoin> join_msg,
|
||||
}
|
||||
int errcode = rsp_obj->Get("errcode", "").GetInt();
|
||||
std::string errmsg = rsp_obj->Get("errmsg", "").GetString();
|
||||
if (!errcode) {
|
||||
if (errcode) {
|
||||
cb(1, "", nullptr);
|
||||
return;
|
||||
}
|
||||
std::string room_uuid = rsp_obj->Get("team_uuid", "").GetString();
|
||||
std::string room_uuid = rsp_obj->Get("room_uuid", "").GetString();
|
||||
if (room_uuid.empty()) {
|
||||
cb(1, "custom battle data error", nullptr);
|
||||
return;
|
||||
|
@ -34,7 +34,7 @@ class VirtualClient(object):
|
||||
self.ws_url = ws_url
|
||||
self.account = account
|
||||
self.account = '6513_2006_1'
|
||||
self.sessionId = '1695476535_1692266254_adec4abd04728e3257a0cf9ea17c7a37_d28b583b8a1d132a15f7c728f40d1675'
|
||||
self.sessionId = '1695521308_1692266254_60c75cd562b135bf5e5f07b7c64b64ac_6172cf18b57c6867085fc7b5087e9032'
|
||||
print(self.ws_url)
|
||||
|
||||
@gen.coroutine
|
||||
|
Loading…
x
Reference in New Issue
Block a user