diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 73db22cf..08aa0c96 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -8,6 +8,7 @@ #include "android_agent.h" #include "player.h" +#include "playermgr.h" #include "httpproxy.h" AndroidAgent::AndroidAgent() @@ -30,7 +31,7 @@ behaviac::EBTStatus AndroidAgent::SearchEnemy(int range) bool AndroidAgent::NetIsConnected() { - return owner_->GetWebSocket()->Connected(); + return owner_->GetWebSocket()->Connected() != 0; } 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("account_id", account_id); url_params->SetVal("session_id", session_id); + auto hum = PlayerMgr::Instance()->GetPlayerByAccountId(account_id); + if (hum) { + hum->SetSessionId(session_id); + } HttpProxy::Instance()->HttpGet ( [context] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) @@ -168,7 +173,7 @@ behaviac::EBTStatus AndroidAgent::CoConnectBattleServer() behaviac::EBTStatus AndroidAgent::CoJoin() { cs::CMJoin msg; - msg.set_server_id(1); + msg.set_server_id(6); msg.set_team_uuid(""); msg.set_account_id(owner_->GetAccountId()); msg.set_team_mode(2); @@ -176,6 +181,8 @@ behaviac::EBTStatus AndroidAgent::CoJoin() msg.set_auto_fill(1); msg.set_name(""); msg.set_avatar_url(""); + msg.set_mapid(2007); + msg.set_hero_id(30800); //weapons msg.set_session_id(owner_->GetSessionId()); owner_->SendMsg(msg); diff --git a/server/robotserver/player.cc b/server/robotserver/player.cc index ebc92511..320e2458 100644 --- a/server/robotserver/player.cc +++ b/server/robotserver/player.cc @@ -31,12 +31,13 @@ void Player::Init(int idx, const std::string& account_id) f8::BtMgr::Instance()->BtSetCurrent(agent_, "android/test"); std::shared_ptr socket; + idx_ = idx; socket_handle_ = idx; account_id_ = account_id; web_socket_ = std::make_shared ( IoMgr::Instance()->GetIoContext(0), - "192.168.100.21", + "192.168.100.45", 7601 ); web_socket_->on_decode_userpacket = diff --git a/server/robotserver/player.h b/server/robotserver/player.h index b37673af..2192f2dc 100644 --- a/server/robotserver/player.h +++ b/server/robotserver/player.h @@ -31,6 +31,7 @@ public: bool NetConnected() { return net_connected_; } const std::string& GetAccountId() { return account_id_; } const std::string& GetSessionId() { return session_id_; } + void SetSessionId(const std::string& session_id) { session_id_ = session_id; } auto GetWebSocket() { return web_socket_; } int GetIdx() { return idx_; } void SetLoginSucess(); diff --git a/server/robotserver/playermgr.cc b/server/robotserver/playermgr.cc index cdcda1b9..0b1c06ae 100644 --- a/server/robotserver/playermgr.cc +++ b/server/robotserver/playermgr.cc @@ -17,9 +17,9 @@ void PlayerMgr::Init() { - for (int i = 1; i < 10; ++i) { + for (int i = 1; i <= 1; ++i) { int idx = i; - std::string account_id; + std::string account_id = a8::Format("6513_2006_%d", {idx}); auto hum = std::make_shared(); hum->Init(idx, account_id); account_id_hash_[hum->GetAccountId()] = hum;