1
This commit is contained in:
parent
9a2371f8a6
commit
206f07055c
@ -13,6 +13,7 @@
|
|||||||
#include "httpproxy.h"
|
#include "httpproxy.h"
|
||||||
#include "tracemgr.h"
|
#include "tracemgr.h"
|
||||||
#include "iomgr.h"
|
#include "iomgr.h"
|
||||||
|
#include "GGListener.h"
|
||||||
|
|
||||||
#include "mt/MetaMgr.h"
|
#include "mt/MetaMgr.h"
|
||||||
|
|
||||||
@ -30,10 +31,12 @@ void App::Init()
|
|||||||
PlayerMgr::Instance()->Init();
|
PlayerMgr::Instance()->Init();
|
||||||
HttpProxy::Instance()->Init();
|
HttpProxy::Instance()->Init();
|
||||||
IoMgr::Instance()->Init();
|
IoMgr::Instance()->Init();
|
||||||
|
GGListener::Instance()->Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::UnInit()
|
void App::UnInit()
|
||||||
{
|
{
|
||||||
|
GGListener::Instance()->UnInit();
|
||||||
IoMgr::Instance()->UnInit();
|
IoMgr::Instance()->UnInit();
|
||||||
PlayerMgr::Instance()->UnInit();
|
PlayerMgr::Instance()->UnInit();
|
||||||
HttpProxy::Instance()->UnInit();
|
HttpProxy::Instance()->UnInit();
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#include <a8/promise.h>
|
#include <a8/promise.h>
|
||||||
#include <a8/websocketclient.h>
|
#include <a8/websocketclient.h>
|
||||||
|
|
||||||
#include <f8/coroutine.h>
|
|
||||||
#include <f8/comgr.h>
|
|
||||||
#include <f8/udplog.h>
|
#include <f8/udplog.h>
|
||||||
#include <f8/utils.h>
|
#include <f8/utils.h>
|
||||||
|
|
||||||
@ -78,59 +76,6 @@ void Player::Init(int idx,
|
|||||||
f8::UdpLog::Instance()->Warning("收到client非法数据包", {});
|
f8::UdpLog::Instance()->Warning("收到client非法数据包", {});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
f8::CoMgr::Instance()->CreateCo
|
|
||||||
(
|
|
||||||
[this] (f8::Coroutine* co)
|
|
||||||
{
|
|
||||||
CoGame(co);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::CoGame(f8::Coroutine* co)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
web_socket_->Open();
|
|
||||||
while (!net_connected_) {
|
|
||||||
co->CoYield();
|
|
||||||
}
|
|
||||||
f8::UdpLog::Instance()->Info
|
|
||||||
("WebSocketClient on_connect ok", {});
|
|
||||||
}
|
|
||||||
{
|
|
||||||
cs::CMJoin msg;
|
|
||||||
msg.set_server_id(6);
|
|
||||||
msg.set_account_id(account_id_);
|
|
||||||
msg.set_session_id(session_id_);
|
|
||||||
msg.set_hero_id(30800);
|
|
||||||
SendMsg(msg);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
while (!join_ok_) {
|
|
||||||
co->CoYield();
|
|
||||||
}
|
|
||||||
f8::UdpLog::Instance()->Info
|
|
||||||
("join ok", {});
|
|
||||||
}
|
|
||||||
{
|
|
||||||
int seq_id = 0;
|
|
||||||
long long last_ping_tick = a8::XGetTickCount();
|
|
||||||
long long last_cmmove_tick = a8::XGetTickCount();
|
|
||||||
while (true) {
|
|
||||||
long long tick = a8::XGetTickCount();
|
|
||||||
if (tick - last_ping_tick > 1000) {
|
|
||||||
cs::CMPing msg;
|
|
||||||
SendMsg(msg);
|
|
||||||
last_ping_tick = tick;
|
|
||||||
}
|
|
||||||
if (tick - last_cmmove_tick >= 100) {
|
|
||||||
cs::CMMove msg;
|
|
||||||
msg.set_seq(++seq_id);
|
|
||||||
SendMsg(msg);
|
|
||||||
last_cmmove_tick = tick;
|
|
||||||
}
|
|
||||||
co->CoYield();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::InternalSendMsg(int msgid, ::google::protobuf::Message& msg)
|
void Player::InternalSendMsg(int msgid, ::google::protobuf::Message& msg)
|
||||||
|
@ -8,11 +8,6 @@ namespace a8
|
|||||||
class WebSocketClient;
|
class WebSocketClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace f8
|
|
||||||
{
|
|
||||||
class Coroutine;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -66,7 +61,6 @@ public:
|
|||||||
void _SMNewBieEnd(f8::MsgHdr* hdr, const cs::SMNewBieEnd& msg);
|
void _SMNewBieEnd(f8::MsgHdr* hdr, const cs::SMNewBieEnd& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CoGame(f8::Coroutine* co);
|
|
||||||
void InternalSendMsg(int msgid, ::google::protobuf::Message& msg);
|
void InternalSendMsg(int msgid, ::google::protobuf::Message& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user