102 lines
2.0 KiB
C++
102 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <a8/uuid.h>
|
|
#include <a8/singleton.h>
|
|
|
|
#include <f8/protoutils.h>
|
|
|
|
struct MsgNode;
|
|
class App : public a8::Singleton<App>
|
|
{
|
|
private:
|
|
App() {};
|
|
friend class a8::Singleton<App>;
|
|
|
|
public:
|
|
#ifdef DEBUG
|
|
std::map<int, int> debug_params;
|
|
#endif
|
|
|
|
bool Init(int argc, char* argv[]);
|
|
void UnInit();
|
|
|
|
int Run();
|
|
|
|
void AddSocketMsg(SocketFrom_e sockfrom,
|
|
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;
|
|
|
|
};
|