This commit is contained in:
aozhiwei 2023-12-06 11:36:55 +08:00
parent 5bfcdb5700
commit d27dfdb922
4 changed files with 14 additions and 5 deletions

View File

@ -8,6 +8,7 @@
#include "android_agent.h" #include "android_agent.h"
#include "player.h" #include "player.h"
#include "playermgr.h"
#include "httpproxy.h" #include "httpproxy.h"
AndroidAgent::AndroidAgent() AndroidAgent::AndroidAgent()
@ -30,7 +31,7 @@ behaviac::EBTStatus AndroidAgent::SearchEnemy(int range)
bool AndroidAgent::NetIsConnected() bool AndroidAgent::NetIsConnected()
{ {
return owner_->GetWebSocket()->Connected(); return owner_->GetWebSocket()->Connected() != 0;
} }
behaviac::EBTStatus AndroidAgent::CoIdle(int min_val, int max_val) behaviac::EBTStatus AndroidAgent::CoIdle(int min_val, int max_val)
@ -80,6 +81,10 @@ behaviac::EBTStatus AndroidAgent::CoLogin()
url_params->SetVal("a", "login"); url_params->SetVal("a", "login");
url_params->SetVal("account_id", account_id); url_params->SetVal("account_id", account_id);
url_params->SetVal("session_id", session_id); url_params->SetVal("session_id", session_id);
auto hum = PlayerMgr::Instance()->GetPlayerByAccountId(account_id);
if (hum) {
hum->SetSessionId(session_id);
}
HttpProxy::Instance()->HttpGet HttpProxy::Instance()->HttpGet
( (
[context] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) [context] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
@ -168,7 +173,7 @@ behaviac::EBTStatus AndroidAgent::CoConnectBattleServer()
behaviac::EBTStatus AndroidAgent::CoJoin() behaviac::EBTStatus AndroidAgent::CoJoin()
{ {
cs::CMJoin msg; cs::CMJoin msg;
msg.set_server_id(1); msg.set_server_id(6);
msg.set_team_uuid(""); msg.set_team_uuid("");
msg.set_account_id(owner_->GetAccountId()); msg.set_account_id(owner_->GetAccountId());
msg.set_team_mode(2); msg.set_team_mode(2);
@ -176,6 +181,8 @@ behaviac::EBTStatus AndroidAgent::CoJoin()
msg.set_auto_fill(1); msg.set_auto_fill(1);
msg.set_name(""); msg.set_name("");
msg.set_avatar_url(""); msg.set_avatar_url("");
msg.set_mapid(2007);
msg.set_hero_id(30800);
//weapons //weapons
msg.set_session_id(owner_->GetSessionId()); msg.set_session_id(owner_->GetSessionId());
owner_->SendMsg(msg); owner_->SendMsg(msg);

View File

@ -31,12 +31,13 @@ void Player::Init(int idx, const std::string& account_id)
f8::BtMgr::Instance()->BtSetCurrent(agent_, "android/test"); f8::BtMgr::Instance()->BtSetCurrent(agent_, "android/test");
std::shared_ptr<a8::WebSocketClient> socket; std::shared_ptr<a8::WebSocketClient> socket;
idx_ = idx;
socket_handle_ = idx; socket_handle_ = idx;
account_id_ = account_id; account_id_ = account_id;
web_socket_ = std::make_shared<a8::WebSocketClient> web_socket_ = std::make_shared<a8::WebSocketClient>
( (
IoMgr::Instance()->GetIoContext(0), IoMgr::Instance()->GetIoContext(0),
"192.168.100.21", "192.168.100.45",
7601 7601
); );
web_socket_->on_decode_userpacket = web_socket_->on_decode_userpacket =

View File

@ -31,6 +31,7 @@ public:
bool NetConnected() { return net_connected_; } bool NetConnected() { return net_connected_; }
const std::string& GetAccountId() { return account_id_; } const std::string& GetAccountId() { return account_id_; }
const std::string& GetSessionId() { return session_id_; } const std::string& GetSessionId() { return session_id_; }
void SetSessionId(const std::string& session_id) { session_id_ = session_id; }
auto GetWebSocket() { return web_socket_; } auto GetWebSocket() { return web_socket_; }
int GetIdx() { return idx_; } int GetIdx() { return idx_; }
void SetLoginSucess(); void SetLoginSucess();

View File

@ -17,9 +17,9 @@
void PlayerMgr::Init() void PlayerMgr::Init()
{ {
for (int i = 1; i < 10; ++i) { for (int i = 1; i <= 1; ++i) {
int idx = i; int idx = i;
std::string account_id; std::string account_id = a8::Format("6513_2006_%d", {idx});
auto hum = std::make_shared<Player>(); auto hum = std::make_shared<Player>();
hum->Init(idx, account_id); hum->Init(idx, account_id);
account_id_hash_[hum->GetAccountId()] = hum; account_id_hash_[hum->GetAccountId()] = hum;