1
This commit is contained in:
parent
afc8ceddac
commit
85a9e56a34
@ -1,106 +1,34 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <mutex>
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
#include <a8/uuid.h>
|
|
||||||
#include <a8/collision.h>
|
|
||||||
#include <a8/magicenum.h>
|
|
||||||
#include <a8/lisp.h>
|
|
||||||
|
|
||||||
#include <f8/udplog.h>
|
#include <f8/udplog.h>
|
||||||
#include <f8/netmsghandler.h>
|
#include <f8/btmgr.h>
|
||||||
#include <f8/comgr.h>
|
|
||||||
|
|
||||||
#include "app.h"
|
|
||||||
#include "handlermgr.h"
|
|
||||||
#include "httpproxy.h"
|
|
||||||
#include "playermgr.h"
|
|
||||||
#include "iomgr.h"
|
|
||||||
|
|
||||||
#include "ss_msgid.pb.h"
|
|
||||||
#include "ss_proto.pb.h"
|
|
||||||
|
|
||||||
#include "f8/msgqueue.h"
|
|
||||||
#include "f8/tglog.h"
|
|
||||||
#include "f8/httpclientpool.h"
|
|
||||||
#include "f8/btmgr.h"
|
|
||||||
#include <f8/timer.h>
|
#include <f8/timer.h>
|
||||||
|
|
||||||
struct MsgNode
|
#include "app.h"
|
||||||
|
#include "jsondatamgr.h"
|
||||||
|
#include "handlermgr.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include "playermgr.h"
|
||||||
|
#include "httpproxy.h"
|
||||||
|
|
||||||
|
#include "tracemgr.h"
|
||||||
|
|
||||||
|
void App::Init()
|
||||||
{
|
{
|
||||||
SocketFrom_e sockfrom;
|
#ifdef MYDEBUG
|
||||||
int sockhandle;
|
TraceMgr::Instance()->Init("gameserver2006");
|
||||||
unsigned short msgid;
|
|
||||||
unsigned int seqid;
|
|
||||||
long ip_saddr;
|
|
||||||
char* buf;
|
|
||||||
int buflen;
|
|
||||||
MsgNode* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
const char* const PROJ_LOG_ROOT_FMT = "/data/logs/%s/logs";
|
|
||||||
const char* const PROJ_LOG_FILENAME_FMT = "log_$pid_%Y%m%d.log";
|
|
||||||
|
|
||||||
static void SavePerfLog()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool App::Init(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
|
||||||
this->argc = argc;
|
|
||||||
this->argv = argv;
|
|
||||||
|
|
||||||
if (!ParseOpt()) {
|
|
||||||
if (node_id <= 0) {
|
|
||||||
a8::XPrintf("robotserver启动失败,缺少-n参数\n", {});
|
|
||||||
} else if (node_id > MAX_NODE_ID) {
|
|
||||||
a8::XPrintf("robotserver启动失败,-n参数不能大于%d\n", {MAX_NODE_ID});
|
|
||||||
} else if (instance_id <= 0) {
|
|
||||||
a8::XPrintf("robotserver启动失败,缺少-i参数\n", {});
|
|
||||||
} else if (instance_id > MAX_INSTANCE_ID) {
|
|
||||||
a8::XPrintf("robotserver启动失败,-i参数不能大于%d\n", {MAX_INSTANCE_ID});
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int debug_mode = 0;
|
|
||||||
#ifdef DEBUG
|
|
||||||
debug_mode = 1;
|
|
||||||
#endif
|
#endif
|
||||||
a8::XPrintf("robotserver starting node_id: %d instance_id:%d pid:%d game_id:%d debug_mode:%d\n",
|
|
||||||
{
|
|
||||||
node_id,
|
|
||||||
instance_id,
|
|
||||||
getpid(),
|
|
||||||
GAME_ID,
|
|
||||||
debug_mode
|
|
||||||
});
|
|
||||||
|
|
||||||
loop_mutex_ = new std::mutex();
|
|
||||||
loop_cond_ = new std::condition_variable();
|
|
||||||
msg_mutex_ = new std::mutex();
|
|
||||||
|
|
||||||
srand(time(nullptr));
|
|
||||||
InitLog();
|
|
||||||
f8::MsgQueue::Instance()->Init();
|
|
||||||
HandlerMgr::Instance()->Init();
|
HandlerMgr::Instance()->Init();
|
||||||
f8::Timer::Instance()->Init();
|
|
||||||
f8::TGLog::Instance()->Init(a8::Format(PROJ_NAME_FMT, {GAME_ID}), false, 0);
|
|
||||||
f8::CoMgr::Instance()->Init();
|
|
||||||
f8::HttpClientPool::Instance()->Init(MAX_ALL_HTTP_NUM, MAX_SYS_HTTP_NUM, MAX_USER_HTTP_NUM);
|
|
||||||
f8::BtMgr::Instance()->Init("exported");
|
f8::BtMgr::Instance()->Init("exported");
|
||||||
#ifdef DEBUG
|
#ifdef MYDEBUG1
|
||||||
f8::BtMgr::Instance()->SetLogging(true);
|
f8::BtMgr::Instance()->SetLogging(true);
|
||||||
#endif
|
#endif
|
||||||
uuid.SetMachineId((node_id - 1) * MAX_NODE_ID + instance_id);
|
JsonDataMgr::Instance()->Init();
|
||||||
IoMgr::Instance()->Init();
|
mt::MetaMgr::Instance()->Init();
|
||||||
HttpProxy::Instance()->Init();
|
|
||||||
PlayerMgr::Instance()->Init();
|
PlayerMgr::Instance()->Init();
|
||||||
|
HttpProxy::Instance()->Init();
|
||||||
{
|
{
|
||||||
int perf_log_time = 1000 * 30;
|
int perf_log_time = 1000 * 30;
|
||||||
f8::Timer::Instance()->SetInterval
|
f8::Timer::Instance()->SetInterval
|
||||||
@ -112,337 +40,44 @@ bool App::Init(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (HasFlag(7)) {
|
|
||||||
f8::Timer::Instance()->SetTimeout
|
|
||||||
(
|
|
||||||
1000 * 60 * 1,
|
|
||||||
[] (int event, const a8::Args* args)
|
|
||||||
{
|
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
|
||||||
App::Instance()->terminated = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::UnInit()
|
void App::UnInit()
|
||||||
{
|
{
|
||||||
//const char* s2 = GetEnumString<int>();
|
|
||||||
//int i = static_cast<int>(Test_e::kFlyBuffId);
|
|
||||||
PlayerMgr::Instance()->UnInit();
|
PlayerMgr::Instance()->UnInit();
|
||||||
IoMgr::Instance()->UnInit();
|
|
||||||
HttpProxy::Instance()->UnInit();
|
HttpProxy::Instance()->UnInit();
|
||||||
|
JsonDataMgr::Instance()->UnInit();
|
||||||
f8::BtMgr::Instance()->UnInit();
|
f8::BtMgr::Instance()->UnInit();
|
||||||
f8::HttpClientPool::Instance()->UnInit();
|
|
||||||
HandlerMgr::Instance()->UnInit();
|
HandlerMgr::Instance()->UnInit();
|
||||||
f8::CoMgr::Instance()->UnInit();
|
#ifdef MYDEBUG
|
||||||
f8::MsgQueue::Instance()->UnInit();
|
TraceMgr::Instance()->UnInit();
|
||||||
f8::Timer::Instance()->UnInit();
|
#endif
|
||||||
f8::TGLog::Instance()->UnInit();
|
|
||||||
UnInitLog();
|
|
||||||
|
|
||||||
FreeSocketMsgQueue();
|
|
||||||
A8_SAFE_DELETE(msg_mutex_);
|
|
||||||
A8_SAFE_DELETE(loop_cond_);
|
|
||||||
A8_SAFE_DELETE(loop_mutex_);
|
|
||||||
}
|
|
||||||
|
|
||||||
int App::Run()
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
f8::UdpLog::Instance()->Info("robotserver running", {});
|
|
||||||
last_run_tick_ = a8::XGetTickCount();
|
|
||||||
int delta_time = 0;
|
|
||||||
while (!terminated) {
|
|
||||||
a8::tick_t begin_tick = a8::XGetTickCount();
|
|
||||||
QuickExecute(delta_time);
|
|
||||||
SlowerExecute(delta_time);
|
|
||||||
Schedule();
|
|
||||||
a8::tick_t end_tick = a8::XGetTickCount();
|
|
||||||
delta_time = end_tick - begin_tick;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::AddSocketMsg(SocketFrom_e sockfrom,
|
|
||||||
int sockhandle,
|
|
||||||
long ip_saddr,
|
|
||||||
unsigned short msgid,
|
|
||||||
unsigned int seqid,
|
|
||||||
const char *msgbody,
|
|
||||||
int bodylen)
|
|
||||||
{
|
|
||||||
MsgNode *p = (MsgNode*) malloc(sizeof(MsgNode));
|
|
||||||
memset(p, 0, sizeof(MsgNode));
|
|
||||||
p->sockfrom = sockfrom;
|
|
||||||
p->ip_saddr = ip_saddr;
|
|
||||||
p->sockhandle = sockhandle;
|
|
||||||
p->msgid = msgid;
|
|
||||||
p->seqid = seqid;
|
|
||||||
p->buf = nullptr;
|
|
||||||
p->buflen = bodylen;
|
|
||||||
if (bodylen > 0) {
|
|
||||||
p->buf = (char*)malloc(bodylen);
|
|
||||||
memmove(p->buf, msgbody, bodylen);
|
|
||||||
}
|
|
||||||
msg_mutex_->lock();
|
|
||||||
if (bot_node_) {
|
|
||||||
bot_node_->next = p;
|
|
||||||
bot_node_ = p;
|
|
||||||
} else {
|
|
||||||
top_node_ = p;
|
|
||||||
bot_node_ = p;
|
|
||||||
}
|
|
||||||
++msgnode_size_;
|
|
||||||
msg_mutex_->unlock();
|
|
||||||
NotifyLoopCond();
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::QuickExecute(int delta_time)
|
|
||||||
{
|
|
||||||
f8::MsgQueue::Instance()->Update();
|
|
||||||
IoMgr::Instance()->Update();
|
|
||||||
DispatchMsg();
|
|
||||||
f8::Timer::Instance()->Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::SlowerExecute(int delta_time)
|
|
||||||
{
|
|
||||||
f8::CoMgr::Instance()->Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::NotifyLoopCond()
|
|
||||||
{
|
|
||||||
std::unique_lock<std::mutex> lk(*loop_mutex_);
|
|
||||||
loop_cond_->notify_all();
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::Schedule()
|
|
||||||
{
|
|
||||||
std::unique_lock<std::mutex> lk(*loop_mutex_);
|
|
||||||
loop_cond_->wait_for(lk, std::chrono::milliseconds(1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool App::HasTask()
|
bool App::HasTask()
|
||||||
{
|
{
|
||||||
{
|
|
||||||
if (!work_node_) {
|
|
||||||
msg_mutex_->lock();
|
|
||||||
if (!work_node_ && top_node_) {
|
|
||||||
work_node_ = top_node_;
|
|
||||||
top_node_ = nullptr;
|
|
||||||
bot_node_ = nullptr;
|
|
||||||
}
|
|
||||||
msg_mutex_->unlock();
|
|
||||||
}
|
|
||||||
if (work_node_) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::DispatchMsg()
|
void App::ProcessGameGateMsg(f8::MsgHdr* hdr)
|
||||||
{
|
{
|
||||||
long long begin_tick = a8::XGetTickCount();
|
f8::NetMsgHandler* handler = f8::GetNetMsgHandler
|
||||||
if (!work_node_ && top_node_) {
|
(&HandlerMgr::Instance()->ggmsghandler,
|
||||||
msg_mutex_->lock();
|
hdr->msgid);
|
||||||
work_node_ = top_node_;
|
|
||||||
top_node_ = nullptr;
|
|
||||||
bot_node_ = nullptr;
|
|
||||||
working_msgnode_size_ = msgnode_size_;
|
|
||||||
msg_mutex_->unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
f8::MsgHdr hdr;
|
|
||||||
while (work_node_) {
|
|
||||||
MsgNode *pdelnode = work_node_;
|
|
||||||
work_node_ = pdelnode->next;
|
|
||||||
hdr.msgid = pdelnode->msgid;
|
|
||||||
hdr.seqid = pdelnode->seqid;
|
|
||||||
hdr.socket_handle = pdelnode->sockhandle;
|
|
||||||
hdr.buf = pdelnode->buf;
|
|
||||||
hdr.buflen = pdelnode->buflen;
|
|
||||||
hdr.offset = 0;
|
|
||||||
hdr.ip_saddr = pdelnode->ip_saddr;
|
|
||||||
switch (pdelnode->sockfrom) {
|
|
||||||
case SF_GameServer:
|
|
||||||
{
|
|
||||||
ProcessGameServerMsg(hdr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (pdelnode->buf) {
|
|
||||||
free(pdelnode->buf);
|
|
||||||
}
|
|
||||||
free(pdelnode);
|
|
||||||
working_msgnode_size_--;
|
|
||||||
if (a8::XGetTickCount() - begin_tick > 200) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}//end while
|
|
||||||
|
|
||||||
if (!work_node_) {
|
|
||||||
working_msgnode_size_ = 0;
|
|
||||||
}
|
|
||||||
a8::tick_t end_tick = a8::XGetTickCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::ProcessGameServerMsg(f8::MsgHdr& hdr)
|
|
||||||
{
|
|
||||||
f8::NetMsgHandler* handler = f8::GetNetMsgHandler(&HandlerMgr::Instance()->gsmsghandler,
|
|
||||||
hdr.msgid);
|
|
||||||
if (handler) {
|
if (handler) {
|
||||||
switch (handler->handlerid) {
|
|
||||||
case HID_Player:
|
|
||||||
{
|
|
||||||
auto player = PlayerMgr::Instance()->GetPlayerBySocketHandle(hdr.socket_handle);
|
|
||||||
if (player) {
|
|
||||||
ProcessNetMsg(handler, player.get(), hdr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::InitLog()
|
const std::string App::GetPkgName()
|
||||||
{
|
{
|
||||||
std::string filename_fmt = PROJ_LOG_FILENAME_FMT;
|
return a8::Format("robotserver2006", {});
|
||||||
a8::ReplaceString(filename_fmt, "$pid", a8::XValue(getpid()));
|
|
||||||
|
|
||||||
std::string proj_root_dir = a8::Format(PROJ_ROOT_FMT, {a8::Format(PROJ_NAME_FMT,{GAME_ID})});
|
|
||||||
std::string proj_log_root_dir = a8::Format(PROJ_LOG_ROOT_FMT, {a8::Format(PROJ_NAME_FMT, {GAME_ID})});
|
|
||||||
std::string log_file_name = a8::Format(PROJ_LOG_ROOT_FMT,
|
|
||||||
{a8::Format(PROJ_NAME_FMT, {GAME_ID})}) + "/" + filename_fmt;
|
|
||||||
|
|
||||||
a8::MkDir(proj_root_dir);
|
|
||||||
a8::MkDir(proj_log_root_dir);
|
|
||||||
f8::UdpLog::Instance()->SetLogFileName(log_file_name);
|
|
||||||
f8::UdpLog::Instance()->Init();
|
|
||||||
f8::UdpLog::Instance()->Info("proj_root_dir:%s", {proj_root_dir});
|
|
||||||
f8::UdpLog::Instance()->Info("proj_log_root_dir:%s", {proj_log_root_dir});
|
|
||||||
f8::UdpLog::Instance()->Info("log_file_name:%s", {log_file_name});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::UnInitLog()
|
void App::Update(int delta_time)
|
||||||
{
|
{
|
||||||
f8::UdpLog::Instance()->UnInit();
|
RoomMgr::Instance()->Update(delta_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool App::ParseOpt()
|
void App::DispatchSocketMsg(f8::MsgHdr* hdr)
|
||||||
{
|
{
|
||||||
int ch = 0;
|
|
||||||
while ((ch = getopt(argc, argv, "i:t:r:f:n:r:")) != -1) {
|
|
||||||
switch (ch) {
|
|
||||||
case 'n':
|
|
||||||
{
|
|
||||||
node_id = a8::XValue(optarg);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
{
|
|
||||||
instance_id = a8::XValue(optarg);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
{
|
|
||||||
is_test_mode = true;
|
|
||||||
test_param = a8::XValue(optarg);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
{
|
|
||||||
std::vector<std::string> strings;
|
|
||||||
a8::Split(optarg, strings, ',');
|
|
||||||
for (auto& str : strings) {
|
|
||||||
flags.insert(a8::XValue(str).GetInt());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
{
|
|
||||||
robot_num = a8::XValue(optarg);
|
|
||||||
robot_num = std::min(robot_num, 100);
|
|
||||||
robot_num = std::max(robot_num, 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return instance_id > 0 && node_id > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
long long App::NewUuid()
|
|
||||||
{
|
|
||||||
return uuid.Generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool App::HasFlag(int flag)
|
|
||||||
{
|
|
||||||
return flags.find(flag) != flags.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::SetFlag(int flag)
|
|
||||||
{
|
|
||||||
flags.insert(flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::UnSetFlag(int flag)
|
|
||||||
{
|
|
||||||
flags.erase(flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::FreeSocketMsgQueue()
|
|
||||||
{
|
|
||||||
msg_mutex_->lock();
|
|
||||||
if (!work_node_) {
|
|
||||||
work_node_ = top_node_;
|
|
||||||
top_node_ = nullptr;
|
|
||||||
bot_node_ = nullptr;
|
|
||||||
}
|
|
||||||
while (work_node_) {
|
|
||||||
MsgNode* pdelnode = work_node_;
|
|
||||||
work_node_ = work_node_->next;
|
|
||||||
if (pdelnode->buf) {
|
|
||||||
free(pdelnode->buf);
|
|
||||||
}
|
|
||||||
free(pdelnode);
|
|
||||||
if (!work_node_) {
|
|
||||||
work_node_ = top_node_;
|
|
||||||
top_node_ = nullptr;
|
|
||||||
bot_node_ = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg_mutex_->unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
long long App::AllocTempHeroUniId()
|
|
||||||
{
|
|
||||||
if (curr_uniid_ < 1000) {
|
|
||||||
curr_uniid_ = 1000;
|
|
||||||
}
|
|
||||||
if (curr_uniid_ > 100000000) {
|
|
||||||
curr_uniid_ = 1001;
|
|
||||||
}
|
|
||||||
++curr_uniid_;
|
|
||||||
return -curr_uniid_;
|
|
||||||
}
|
|
||||||
|
|
||||||
long long App::AllocTempWeaponUniId()
|
|
||||||
{
|
|
||||||
if (curr_uniid_ < 1000) {
|
|
||||||
curr_uniid_ = 1000;
|
|
||||||
}
|
|
||||||
if (curr_uniid_ > 100000000) {
|
|
||||||
curr_uniid_ = 1000;
|
|
||||||
}
|
|
||||||
++curr_uniid_;
|
|
||||||
return -curr_uniid_;
|
|
||||||
}
|
}
|
||||||
|
@ -1,101 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <a8/uuid.h>
|
|
||||||
#include <a8/singleton.h>
|
#include <a8/singleton.h>
|
||||||
|
#include <f8/app.h>
|
||||||
|
|
||||||
#include <f8/protoutils.h>
|
class App : public f8::UserApp, public a8::Singleton<App>
|
||||||
|
|
||||||
struct MsgNode;
|
|
||||||
class App : public a8::Singleton<App>
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
App() {};
|
App() {};
|
||||||
friend class a8::Singleton<App>;
|
friend class a8::Singleton<App>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifdef DEBUG
|
|
||||||
std::map<int, int> debug_params;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool Init(int argc, char* argv[]);
|
virtual const std::string GetPkgName() override;
|
||||||
void UnInit();
|
virtual void Init() override;
|
||||||
|
virtual void UnInit() override;
|
||||||
int Run();
|
virtual void Update(int delta_time) override;
|
||||||
|
virtual bool HasTask() override;
|
||||||
void AddSocketMsg(SocketFrom_e sockfrom,
|
virtual void DispatchSocketMsg(f8::MsgHdr* hdr) override;
|
||||||
int sockhandle,
|
|
||||||
long ip_saddr,
|
|
||||||
unsigned short msgid,
|
|
||||||
unsigned int seqid,
|
|
||||||
const char *msgbody,
|
|
||||||
int bodylen);
|
|
||||||
|
|
||||||
void NotifyLoopCond();
|
|
||||||
|
|
||||||
long long NewUuid();
|
|
||||||
bool HasFlag(int flag);
|
|
||||||
void SetFlag(int flag);
|
|
||||||
void UnSetFlag(int flag);
|
|
||||||
long long AllocTempHeroUniId();
|
|
||||||
long long AllocTempWeaponUniId();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void QuickExecute(int delta_time);
|
|
||||||
void SlowerExecute(int delta_time);
|
|
||||||
void Schedule();
|
|
||||||
bool HasTask();
|
|
||||||
|
|
||||||
void DispatchMsg();
|
|
||||||
|
|
||||||
void ProcessGameServerMsg(f8::MsgHdr& hdr);
|
|
||||||
|
|
||||||
void InitLog();
|
|
||||||
void UnInitLog();
|
|
||||||
|
|
||||||
bool ParseOpt();
|
|
||||||
void FreeSocketMsgQueue();
|
|
||||||
|
|
||||||
public:
|
|
||||||
int argc = 0;
|
|
||||||
char** argv = nullptr;
|
|
||||||
volatile bool terminated = false;
|
|
||||||
a8::uuid::SnowFlake uuid;
|
|
||||||
|
|
||||||
public:
|
|
||||||
int instance_id = 0;
|
|
||||||
int node_id = 0;
|
|
||||||
int robot_num = 1;
|
|
||||||
bool is_test_mode = false;
|
|
||||||
int test_param = 0;
|
|
||||||
bool servicing = true;
|
|
||||||
|
|
||||||
private:
|
|
||||||
/*
|
|
||||||
1: 是否自动匹配机器人组队
|
|
||||||
2: 是否发布环境
|
|
||||||
3: battleReport环境
|
|
||||||
4: 打印性能日志
|
|
||||||
5: 压力测试
|
|
||||||
6:
|
|
||||||
7: 内存泄露测试
|
|
||||||
8: httpclientpool压力测试
|
|
||||||
*/
|
|
||||||
std::set<int> flags;
|
|
||||||
|
|
||||||
private:
|
|
||||||
long long last_run_tick_ = 0;
|
|
||||||
std::mutex *loop_mutex_ = nullptr;
|
|
||||||
std::condition_variable *loop_cond_ = nullptr;
|
|
||||||
|
|
||||||
std::mutex *msg_mutex_ = nullptr;
|
|
||||||
MsgNode* top_node_ = nullptr;
|
|
||||||
MsgNode* bot_node_ = nullptr;
|
|
||||||
MsgNode* work_node_ = nullptr;
|
|
||||||
|
|
||||||
long long curr_uniid_ = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
int msgnode_size_ = 0 ;
|
|
||||||
int working_msgnode_size_ = 0;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include <f8/app.h>
|
||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int exitcode = 0;
|
return f8::App::Instance()->Run(argc, argv, App::Instance());
|
||||||
if (App::Instance()->Init(argc, argv)) {
|
|
||||||
exitcode = App::Instance()->Run();
|
|
||||||
App::Instance()->UnInit();
|
|
||||||
}
|
|
||||||
return exitcode;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user