1
This commit is contained in:
parent
5bfcdb5700
commit
d27dfdb922
@ -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);
|
||||
|
@ -31,12 +31,13 @@ void Player::Init(int idx, const std::string& account_id)
|
||||
f8::BtMgr::Instance()->BtSetCurrent(agent_, "android/test");
|
||||
|
||||
std::shared_ptr<a8::WebSocketClient> socket;
|
||||
idx_ = idx;
|
||||
socket_handle_ = idx;
|
||||
account_id_ = account_id;
|
||||
web_socket_ = std::make_shared<a8::WebSocketClient>
|
||||
(
|
||||
IoMgr::Instance()->GetIoContext(0),
|
||||
"192.168.100.21",
|
||||
"192.168.100.45",
|
||||
7601
|
||||
);
|
||||
web_socket_->on_decode_userpacket =
|
||||
|
@ -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();
|
||||
|
@ -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<Player>();
|
||||
hum->Init(idx, account_id);
|
||||
account_id_hash_[hum->GetAccountId()] = hum;
|
||||
|
Loading…
x
Reference in New Issue
Block a user