From a6814e437e0e5878d6cd7e129c0dc079e8331bf6 Mon Sep 17 00:00:00 2001 From: i0gan <42000708+i0gan@users.noreply.github.com> Date: Sat, 27 Apr 2024 21:33:37 +0800 Subject: [PATCH] Update: Move the Node type defines to proto file --- README.md | 2 + src/lua/common/base.lua | 16 ----- src/lua/lib/db/clickhouse.lua | 6 +- src/lua/lib/db/mongo.lua | 10 +-- src/lua/lib/db/mysql.lua | 8 +-- src/lua/lib/db/redis.lua | 4 +- src/lua/main.lua | 4 +- src/node/ds_mgr/logic/logic_module.cc | 2 +- src/node/global/logic/logic_module.cc | 2 +- src/node/login/logic/logic_module.cc | 4 +- src/node/master/logic/logic_module.cc | 4 +- src/node/master/logic/logic_module.h | 2 +- src/node/player/logic/logic_module.cc | 2 +- src/node/proxy/logic/logic_module.cc | 18 +++--- src/node/proxy/logic/logic_module.h | 2 +- src/node/web/logic/logic_module.cc | 2 +- src/node/world/logic/logic_module.cc | 2 +- src/proto/n_master.proto | 50 ++++++++++----- src/squick/core/base.h | 20 ------ src/squick/plugin/lua/lua_script_module.cc | 6 +- src/squick/plugin/lua/lua_script_module.h | 6 +- src/squick/plugin/net/i_net_client_module.h | 23 ++++--- src/squick/plugin/net/i_net_module.h | 4 +- src/squick/plugin/net/net_client_module.cc | 27 +++----- src/squick/plugin/net/net_client_module.h | 13 ++-- src/squick/plugin/net/pb_log_module.cc | 2 +- src/squick/plugin/node/node_module.cc | 70 ++++++++++----------- src/squick/plugin/node/node_module.h | 6 +- src/tools/sqkcli/core/tester_module.cc | 8 +-- src/tutorial/t6_rpc/rpc_module.cc | 2 +- 30 files changed, 151 insertions(+), 176 deletions(-) diff --git a/README.md b/README.md index 91aeef18..dd702e7d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ **Unreal SDK**: [squick-unreal-sdk](https://github.com/pwnsky/squick-unreal-sdk) +**Web Admin**: [squick-web](https://github.com/pwnsky/squick-web) + **QQ Group:739065686** **Version:** 1.1.1 diff --git a/src/lua/common/base.lua b/src/lua/common/base.lua index 37b268dc..e69de29b 100644 --- a/src/lua/common/base.lua +++ b/src/lua/common/base.lua @@ -1,16 +0,0 @@ -ServerType = -{ - ST_NONE = 0, - ST_MASTER = 1, - ST_LOGIN = 2, - ST_WORLD = 3, - ST_DB_PROXY = 4, - ST_PROXY = 5, - ST_PLAYER = 6, - ST_GAME_MGR = 7, - ST_GAME = 8, - ST_MICRO = 9, - ST_CDN = 10, - ST_ROBOT = 11, - ST_MAX = 12, -}; diff --git a/src/lua/lib/db/clickhouse.lua b/src/lua/lib/db/clickhouse.lua index a71ea81e..7b57de68 100644 --- a/src/lua/lib/db/clickhouse.lua +++ b/src/lua/lib/db/clickhouse.lua @@ -9,9 +9,9 @@ local DbClickhouseID = 0; Clickhouse = Clickhouse and Clickhouse or Object(QueryAsync).new() function Clickhouse:Bind() - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckClickhouseExecute, self, self.AckExecute) - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckClickhouseSelect, self, self.AckSelect) - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckClickhouseInsert, self, self.AckInsert) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckClickhouseExecute, self, self.AckExecute) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckClickhouseSelect, self, self.AckSelect) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckClickhouseInsert, self, self.AckInsert) DbClickhouseID = GetDbProxyID() end diff --git a/src/lua/lib/db/mongo.lua b/src/lua/lib/db/mongo.lua index 46d97a29..d74dbcb5 100644 --- a/src/lua/lib/db/mongo.lua +++ b/src/lua/lib/db/mongo.lua @@ -9,11 +9,11 @@ local DbProxyID = 0; Mongo = Mongo and Mongo or Object(QueryAsync).new() function Mongo:Bind() - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckMongoInsert, self, self.AckInsert) - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckMongoFind, self, self.AckFind) - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckMongoUpdate, self, self.AckUpdate) - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckMongoDelete, self, self.AckDelete) - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckMongoCreateIndex, self, self.AckCreateIndex) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckMongoInsert, self, self.AckInsert) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckMongoFind, self, self.AckFind) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckMongoUpdate, self, self.AckUpdate) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckMongoDelete, self, self.AckDelete) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckMongoCreateIndex, self, self.AckCreateIndex) DbProxyID = GetDbProxyID() end diff --git a/src/lua/lib/db/mysql.lua b/src/lua/lib/db/mysql.lua index 7c32195b..eb58889b 100644 --- a/src/lua/lib/db/mysql.lua +++ b/src/lua/lib/db/mysql.lua @@ -9,10 +9,10 @@ local DbMysqlID = 0; Mysql = Mysql and Mysql or Object(QueryAsync).new() function Mysql:Bind() - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckMysqlExecute, self, self.AckExecute) - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckMysqlSelect, self, self.AckSelect) - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckMysqlInsert, self, self.AckInsert) - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckMysqlUpdate, self, self.AckUpdate) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckMysqlExecute, self, self.AckExecute) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckMysqlSelect, self, self.AckSelect) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckMysqlInsert, self, self.AckInsert) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckMysqlUpdate, self, self.AckUpdate) DbMysqlID = GetDbProxyID() end diff --git a/src/lua/lib/db/redis.lua b/src/lua/lib/db/redis.lua index a42afecf..90413e35 100644 --- a/src/lua/lib/db/redis.lua +++ b/src/lua/lib/db/redis.lua @@ -9,8 +9,8 @@ local DbProxyID = 0; Redis = Redis and Redis or Object(QueryAsync).new() function Redis:Bind() - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckRedisGet, self, self.AckGetString) - Net:ClientRegister(ServerType.ST_DB_PROXY, NMsgId.IdNAckRedisSet, self, self.AckSetString) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckRedisGet, self, self.AckGetString) + Net:ClientRegister(NodeType.ST_DB_PROXY, NMsgId.IdNAckRedisSet, self, self.AckSetString) DbProxyID = GetDbProxyID() end diff --git a/src/lua/main.lua b/src/lua/main.lua index 39507eb4..d31043bc 100644 --- a/src/lua/main.lua +++ b/src/lua/main.lua @@ -74,10 +74,10 @@ function Load() Require("lib.init") local node_init = { - [ServerType.ST_GAME ] = function() + [NodeType.ST_GAME ] = function() Require("node.game.init") end, - [ServerType.ST_PLAYER] = function () + [NodeType.ST_PLAYER] = function () Require("node.player.init") -- Require("test.init") end diff --git a/src/node/ds_mgr/logic/logic_module.cc b/src/node/ds_mgr/logic/logic_module.cc index 162a8a3a..3251d3f7 100644 --- a/src/node/ds_mgr/logic/logic_module.cc +++ b/src/node/ds_mgr/logic/logic_module.cc @@ -31,7 +31,7 @@ bool LogicModule::AfterStart() { }*/ // 来自Game 服务器 - m_net_client_->AddReceiveCallBack(ServerType::ST_GAME, rpc::REQ_GAMEPLAY_CREATE, this, &LogicModule::OnReqPvpInstanceCreate); + m_net_client_->AddReceiveCallBack(rpc::ST_GAME, rpc::REQ_GAMEPLAY_CREATE, this, &LogicModule::OnReqPvpInstanceCreate); return true; } diff --git a/src/node/global/logic/logic_module.cc b/src/node/global/logic/logic_module.cc index 0e5131f0..a11b3793 100644 --- a/src/node/global/logic/logic_module.cc +++ b/src/node/global/logic/logic_module.cc @@ -3,7 +3,7 @@ namespace global::logic { bool LogicModule::Start() { m_node_ = pm_->FindModule(); - vector node_types = {ServerType::ST_DB_PROXY}; + vector node_types = {rpc::ST_DB_PROXY}; m_node_->AddSubscribeNode(node_types); return true; } diff --git a/src/node/login/logic/logic_module.cc b/src/node/login/logic/logic_module.cc index 39b2f66d..212c8d18 100644 --- a/src/node/login/logic/logic_module.cc +++ b/src/node/login/logic/logic_module.cc @@ -23,7 +23,7 @@ bool LogicModule::AfterStart() { m_net_->AddReceiveCallBack(rpc::IdNReqConnectProxyVerify, this, &LogicModule::OnConnectProxyVerify); m_http_server_->StartServer(pm_->GetArg("http_port=", 80)); - vector node_types = {ServerType::ST_DB_PROXY}; + vector node_types = {rpc::ST_DB_PROXY}; m_node_->AddSubscribeNode(node_types); return true; } @@ -63,7 +63,7 @@ Coroutine LogicModule::OnLogin(std::shared_ptr request) { // find min work load proxy rpc::NReqMinWorkloadNodeInfo pbreq; - pbreq.add_type_list(ST_PROXY); + pbreq.add_type_list(rpc::ST_PROXY); auto data = co_await m_net_client_->RequestPB(DEFAULT_MASTER_ID, rpc::IdNReqMinWorkloadNodeInfo, pbreq, rpc::IdNAckMinWorkloadNodeInfo); if (data.error) { ack.code = IResponse::SERVER_ERROR; diff --git a/src/node/master/logic/logic_module.cc b/src/node/master/logic/logic_module.cc index 6a0d1210..56806161 100644 --- a/src/node/master/logic/logic_module.cc +++ b/src/node/master/logic/logic_module.cc @@ -205,7 +205,7 @@ void LogicModule::OnNReqMinWorkNodeInfo(const socket_t sock, const int msg_id, c return; } for (auto type : req.type_list()) { - int id = GetLoadBanlanceNode((ServerType)type); + int id = GetLoadBanlanceNode(type); if (id == -1) continue; auto p = ack.add_list(); @@ -216,7 +216,7 @@ void LogicModule::OnNReqMinWorkNodeInfo(const socket_t sock, const int msg_id, c m_net_->SendPBToNode(rpc::IdNAckMinWorkloadNodeInfo, ack, sock, 0, req_id); } -int LogicModule::GetLoadBanlanceNode(ServerType type) { +int LogicModule::GetLoadBanlanceNode(int type) { int node_id = -1; int min_workload = 0x7fffffff; for (auto &iter : node_map_) { diff --git a/src/node/master/logic/logic_module.h b/src/node/master/logic/logic_module.h index b68fc9bf..923946e4 100644 --- a/src/node/master/logic/logic_module.h +++ b/src/node/master/logic/logic_module.h @@ -26,7 +26,7 @@ class LogicModule : public ILogicModule { void OnNNtfNodeMsgForward(const socket_t sock, const int msg_id, const char *msg, const uint32_t len); void OnNReqAllNodesInfo(const socket_t sock, const int msg_id, const char *msg, const uint32_t len); - int GetLoadBanlanceNode(ServerType type); + int GetLoadBanlanceNode(int type); void AddSubscribeNode(int new_node_id, vector types); void NtfSubscribNode(int new_node_id); diff --git a/src/node/player/logic/logic_module.cc b/src/node/player/logic/logic_module.cc index f3afa11f..8fb88b13 100644 --- a/src/node/player/logic/logic_module.cc +++ b/src/node/player/logic/logic_module.cc @@ -7,7 +7,7 @@ namespace player::logic { bool LogicModule::Start() { m_lua_script_ = pm_->FindModule(); m_node_ = pm_->FindModule(); - vector node_types = {ServerType::ST_WORLD, ServerType::ST_DB_PROXY, ServerType::ST_PLAYER}; + vector node_types = {rpc::ST_WORLD, rpc::ST_DB_PROXY, rpc::ST_PLAYER}; m_node_->AddSubscribeNode(node_types); LuaBind(); diff --git a/src/node/proxy/logic/logic_module.cc b/src/node/proxy/logic/logic_module.cc index 60288b09..ec5de2c6 100644 --- a/src/node/proxy/logic/logic_module.cc +++ b/src/node/proxy/logic/logic_module.cc @@ -44,12 +44,12 @@ bool LogicModule::AfterStart() { m_ws_->AddReceiveCallBack(rpc::IdReqPlayerLeave, this, &LogicModule::OnReqPlayerLeave); // Master - m_net_client_->AddReceiveCallBack(ServerType::ST_MASTER, this, &LogicModule::OnNAckMinWorkloadNodeInfo); + m_net_client_->AddReceiveCallBack(rpc::ST_MASTER, this, &LogicModule::OnNAckMinWorkloadNodeInfo); // Lobby - m_net_client_->AddReceiveCallBack(ServerType::ST_PLAYER, this, &LogicModule::OnRecivedPlayerNodeMsg); - m_net_client_->AddReceiveCallBack(ServerType::ST_LOGIN, rpc::IdNAckConnectProxyVerify, this, &LogicModule::OnNAckConnectVerify); - m_net_client_->AddReceiveCallBack(ServerType::ST_PLAYER, rpc::IdAckPlayerEnter, this, &LogicModule::OnAckPlayerEnter); + m_net_client_->AddReceiveCallBack(rpc::ST_PLAYER, this, &LogicModule::OnRecivedPlayerNodeMsg); + m_net_client_->AddReceiveCallBack(rpc::ST_LOGIN, rpc::IdNAckConnectProxyVerify, this, &LogicModule::OnNAckConnectVerify); + m_net_client_->AddReceiveCallBack(rpc::ST_PLAYER, rpc::IdAckPlayerEnter, this, &LogicModule::OnAckPlayerEnter); auto &node_info = m_node_->GetNodeInfo(); node_info.info->set_ws_port(pm_->GetArg("ws_port=", 10502)); @@ -58,7 +58,7 @@ bool LogicModule::AfterStart() { m_ws_->AddEventCallBack(this, &LogicModule::OnSocketEvent); m_net_->AddEventCallBack(this, &LogicModule::OnSocketEvent); - vector node_types = {ServerType::ST_WORLD, ServerType::ST_LOGIN, ServerType::ST_PLAYER}; + vector node_types = {rpc::ST_WORLD, rpc::ST_LOGIN, rpc::ST_PLAYER}; m_node_->AddSubscribeNode(node_types); return true; @@ -80,8 +80,8 @@ void LogicModule::OnSocketEvent(socket_t sock, const SQUICK_NET_EVENT eEvent, IN void LogicModule::NReqMinWorkloadNodeInfo() { // find min work load proxy rpc::NReqMinWorkloadNodeInfo pbreq; - pbreq.add_type_list(ST_PLAYER); - pbreq.add_type_list(ST_WORLD); + pbreq.add_type_list(rpc::ST_PLAYER); + pbreq.add_type_list(rpc::ST_WORLD); m_net_client_->SendPBByID(DEFAULT_MASTER_ID, rpc::IdNReqMinWorkloadNodeInfo, pbreq); } @@ -105,7 +105,7 @@ void LogicModule::OnReqPlayerEnter(const socket_t sock, const int msg_id, const return; } - int player_node = GetLoadBanlanceNode(ST_PLAYER); + int player_node = GetLoadBanlanceNode(rpc::ST_PLAYER); if (player_node <= 0 || pInfo->player_node > 0) { LOG_WARN("No player node find: %v ", player_node); return; @@ -171,7 +171,7 @@ void LogicModule::OnAckPlayerEnter(const socket_t sock, const int msg_id, const } } -int LogicModule::GetLoadBanlanceNode(ServerType type) { +int LogicModule::GetLoadBanlanceNode(int type) { auto iter = min_workload_nodes_.find(type); if (iter == min_workload_nodes_.end()) { return 0; diff --git a/src/node/proxy/logic/logic_module.h b/src/node/proxy/logic/logic_module.h index dd9c8267..86056874 100644 --- a/src/node/proxy/logic/logic_module.h +++ b/src/node/proxy/logic/logic_module.h @@ -84,7 +84,7 @@ class LogicModule : public ILogicModule { void OnWS(const socket_t sock, const int msg_id, const char *msg, const uint32_t len); void OnSocketEvent(socket_t sock, const SQUICK_NET_EVENT eEvent, INet *pNet); - int GetLoadBanlanceNode(ServerType type); + int GetLoadBanlanceNode(int type); PlayerConnInfo *GetPlayerConnInfoByUID(const uint64_t uid); PlayerConnInfo *GetPlayerConnInfo(const socket_t player_sock); bool RemovePlayerConnInfo(const socket_t player_sock); diff --git a/src/node/web/logic/logic_module.cc b/src/node/web/logic/logic_module.cc index f2495de9..e47f8557 100644 --- a/src/node/web/logic/logic_module.cc +++ b/src/node/web/logic/logic_module.cc @@ -25,7 +25,7 @@ bool LogicModule::AfterStart() { m_http_server_->AddRequestHandler(WEB_BASE_PATH "/auth_check", HttpType::SQUICK_HTTP_REQ_GET, this, &LogicModule::OnAuthCheck); m_http_server_->StartServer(pm_->GetArg("http_port=", ARG_DEFAULT_HTTP_PORT)); - vector node_types = {ServerType::ST_GLOBAL, ServerType::ST_DB_PROXY, ServerType::ST_PLAYER}; + vector node_types = {rpc::ST_GLOBAL, rpc::ST_DB_PROXY, rpc::ST_PLAYER}; m_node_->AddSubscribeNode(node_types); LoadConfig(); diff --git a/src/node/world/logic/logic_module.cc b/src/node/world/logic/logic_module.cc index 91a1b7de..0106afe9 100644 --- a/src/node/world/logic/logic_module.cc +++ b/src/node/world/logic/logic_module.cc @@ -3,7 +3,7 @@ namespace world::logic { bool LogicModule::Start() { m_node_ = pm_->FindModule(); - vector node_types = {ServerType::ST_DB_PROXY}; + vector node_types = {rpc::ST_DB_PROXY}; m_node_->AddSubscribeNode(node_types); return true; } diff --git a/src/proto/n_master.proto b/src/proto/n_master.proto index 88e2fd10..b8c5af9f 100644 --- a/src/proto/n_master.proto +++ b/src/proto/n_master.proto @@ -2,21 +2,41 @@ syntax = "proto3"; package rpc; -enum ServerState { - ServerCrash = 0; - ServerNormal = 1; - ServerBusy = 2; - ServerFrie = 3; +enum NodeState { + NodeStateCrash = 0; + NodeStateNormal = 1; + NodeStateBusy = 2; + NodeStateFrie = 3; } -message Server { +enum NodeType { + ST_NONE = 0; // NONE + ST_MASTER = 1; // + ST_LOGIN = 2; // + ST_WORLD = 3; // + ST_DB_PROXY = 4; // + ST_PROXY = 5; // + ST_PLAYER = 6; + ST_GAME_MGR = 7; // + ST_GAME = 8; // + ST_MICRO = 9; // Micro + ST_CDN = 10; // CDN + ST_WEB = 11; // Web + ST_GLOBAL = 12; // Global + ST_ROOM = 13; // Room + ST_MATCH = 14; // Match + ST_GM = 15; // GM + ST_MAX = 16; +} + +message Node { int32 id = 1; bytes name = 2; bytes ip = 3; int32 port = 4; int32 max_online = 5; int32 cpu_count = 6; - ServerState state = 7; + NodeState state = 7; int32 type = 8; int32 area = 9; int32 connections = 10; @@ -33,12 +53,12 @@ message Server { message NReqNodeRegister { // msg_id=500; repeated int32 listen_type_list = 1; // set bind type, When new same type node connect to master, it will ntf self node. - Server node = 2; + Node node = 2; } message NAckNodeRegister { // msg_id=501; int32 code = 1; - repeated Server node_add_list = 2; + repeated Node node_add_list = 2; } message NReqNodeUnregister { // msg_id=502; @@ -54,7 +74,7 @@ message NReqMinWorkloadNodeInfo { // msg_id=504; } message NAckMinWorkloadNodeInfo { // msg_id=505; - repeated Server list = 1; + repeated Node list = 1; } message NReqNodeInfo { // msg_id=506; @@ -62,20 +82,20 @@ message NReqNodeInfo { // msg_id=506; } message NAckNodeInfo { // msg_id=507; - repeated Server list = 1; + repeated Node list = 1; } message NNtfNodeReport { // msg_id=508; desc=Report current node status; int32 id = 1; - repeated Server list = 2; + repeated Node list = 2; } message NNtfNodeAdd { // msg_id=509; - repeated Server node_list = 1; + repeated Node node_list = 1; } message NNtfNodeRemove { // msg_id=510; - repeated Server node_list = 1; + repeated Node node_list = 1; } message NNtfNodeMsgForward { // msg_id=511; @@ -86,5 +106,5 @@ message NReqAllNodesInfo { // msg_id=512; } message NAckAllNodesInfo { // msg_id=513; - repeated Server node_list = 1; + repeated Node node_list = 1; } \ No newline at end of file diff --git a/src/squick/core/base.h b/src/squick/core/base.h index 509f83fa..7adc1d0e 100644 --- a/src/squick/core/base.h +++ b/src/squick/core/base.h @@ -14,26 +14,6 @@ #define SQUICK_VERSION "1.1.1" #define SERVER_NAME "Squick/" SQUICK_VERSION -enum ServerType { - ST_NONE = 0, // NONE - ST_MASTER = 1, // - ST_LOGIN = 2, // - ST_WORLD = 3, // - ST_DB_PROXY = 4, // - ST_PROXY = 5, // - ST_PLAYER = 6, - ST_GAME_MGR = 7, // - ST_GAME = 8, // - ST_MICRO = 9, // Micro - ST_CDN = 10, // CDN - ST_WEB = 11, // Web - ST_GLOBAL = 12, // Global - ST_ROOM = 12, // Room - ST_MATCH = 13, // Match - ST_GM = 14, // GM - ST_MAX = 15, -}; - // 线程池 每一帧睡眠时间,单位毫秒 #define THREAD_POOL_SLEEP_TIME 100 // 主线程 每一帧睡眠时间,单位毫秒 diff --git a/src/squick/plugin/lua/lua_script_module.cc b/src/squick/plugin/lua/lua_script_module.cc index 83e668bb..27ad0b69 100644 --- a/src/squick/plugin/lua/lua_script_module.cc +++ b/src/squick/plugin/lua/lua_script_module.cc @@ -572,10 +572,10 @@ void LuaScriptModule::AddMsgCallBackAsServer(const int msg_id, const LuaIntf::Lu callbackList->Add({luaTable, luaFunc}); } -void LuaScriptModule::RemoveMsgCallBackAsClient(const ServerType serverType, const int msg_id) { m_net_client_->RemoveReceiveCallBack(serverType, msg_id); } +void LuaScriptModule::RemoveMsgCallBackAsClient(const int serverType, const int msg_id) { m_net_client_->RemoveReceiveCallBack(serverType, msg_id); } // 做为服务器做为客户端连接的网络 回调 -void LuaScriptModule::AddMsgCallBackAsClient(const ServerType serverType, const int msg_id, const LuaIntf::LuaRef &luaTable, const LuaIntf::LuaRef &luaFunc) { +void LuaScriptModule::AddMsgCallBackAsClient(const int serverType, const int msg_id, const LuaIntf::LuaRef &luaTable, const LuaIntf::LuaRef &luaFunc) { auto callbackList = mxNetMsgCallBackFuncMapAsClient.GetElement(msg_id); if (!callbackList) { callbackList = new List(); @@ -612,7 +612,7 @@ void LuaScriptModule::SendToServerByServerID(const int server_id, const uint16_t m_net_client_->SendByID(server_id, msg_id, data, uid); } -void LuaScriptModule::SendToAllServerByServerType(const ServerType server_type, const uint16_t msg_id, const std::string &data, const uint64_t uid) { +void LuaScriptModule::SendToAllServerByServerType(const int server_type, const uint16_t msg_id, const std::string &data, const uint64_t uid) { m_net_client_->SendToAllNodeByType(server_type, msg_id, data, uid); } diff --git a/src/squick/plugin/lua/lua_script_module.h b/src/squick/plugin/lua/lua_script_module.h index 43237d28..44cc4673 100644 --- a/src/squick/plugin/lua/lua_script_module.h +++ b/src/squick/plugin/lua/lua_script_module.h @@ -130,15 +130,15 @@ class LuaScriptModule : public ILuaScriptModule { void AddMsgCallBackAsServer(const int msg_id, const LuaIntf::LuaRef &luaTable, const LuaIntf::LuaRef &luaFunc); // as client - void RemoveMsgCallBackAsClient(const ServerType serverType, const int msg_id); - void AddMsgCallBackAsClient(const ServerType serverType, const int msg_id, const LuaIntf::LuaRef &luaTable, const LuaIntf::LuaRef &luaFunc); + void RemoveMsgCallBackAsClient(const int serverType, const int msg_id); + void AddMsgCallBackAsClient(const int serverType, const int msg_id, const LuaIntf::LuaRef &luaTable, const LuaIntf::LuaRef &luaFunc); bool ImportProtoFile(const std::string &fileName); const std::string Encode(const std::string &msgTypeName, const LuaIntf::LuaRef &luaTable); LuaIntf::LuaRef Decode(const std::string &msgTypeName, const std::string &data); void SendToServerByServerID(const int server_id, const uint16_t msg_id, const std::string &data, const uint64_t uid); - void SendToAllServerByServerType(const ServerType server_type, const uint16_t msg_id, const std::string &data, const uint64_t uid); + void SendToAllServerByServerType(const int server_type, const uint16_t msg_id, const std::string &data, const uint64_t uid); // for net module void SendByFD(const socket_t fd, const uint16_t msg_id, const std::string &data, const uint64_t uid); diff --git a/src/squick/plugin/net/i_net_client_module.h b/src/squick/plugin/net/i_net_client_module.h index 32efd973..2b08f09a 100644 --- a/src/squick/plugin/net/i_net_client_module.h +++ b/src/squick/plugin/net/i_net_client_module.h @@ -19,14 +19,14 @@ struct ConnectData { port = 0; name = ""; ip = ""; - type = ST_NONE; + type = 0; state = ConnectDataState::DISCONNECT; last_time = 0; buffer_size = 0; } int id; - ServerType type; + int type; std::string ip; int port; std::string name; @@ -53,7 +53,7 @@ class INetClientModule : public IModule { }; template - bool AddReceiveCallBack(const ServerType eType, const uint16_t msg_id, BaseType *pBase, + bool AddReceiveCallBack(const int eType, const uint16_t msg_id, BaseType *pBase, void (BaseType::*handleReceiver)(const socket_t, const int, const char *, const uint32_t)) { NET_RECEIVE_FUNCTOR functor = std::bind(handleReceiver, pBase, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4); @@ -65,7 +65,7 @@ class INetClientModule : public IModule { } template - int AddReceiveCallBack(const ServerType eType, BaseType *pBase, void (BaseType::*handleReceiver)(const socket_t, const int, const char *, const uint32_t)) { + int AddReceiveCallBack(const int eType, BaseType *pBase, void (BaseType::*handleReceiver)(const socket_t, const int, const char *, const uint32_t)) { NET_RECEIVE_FUNCTOR functor = std::bind(handleReceiver, pBase, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4); NET_RECEIVE_FUNCTOR_PTR functorPtr(new NET_RECEIVE_FUNCTOR(functor)); @@ -76,7 +76,7 @@ class INetClientModule : public IModule { } template - bool AddEventCallBack(const ServerType eType, BaseType *pBase, void (BaseType::*handler)(const socket_t, const SQUICK_NET_EVENT, INet *)) { + bool AddEventCallBack(const int eType, BaseType *pBase, void (BaseType::*handler)(const socket_t, const SQUICK_NET_EVENT, INet *)) { NET_EVENT_FUNCTOR functor = std::bind(handler, pBase, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); NET_EVENT_FUNCTOR_PTR functorPtr(new NET_EVENT_FUNCTOR(functor)); @@ -85,11 +85,11 @@ class INetClientModule : public IModule { return true; } - virtual int AddReceiveCallBack(const ServerType eType, NET_RECEIVE_FUNCTOR_PTR functorPtr) = 0; - virtual int AddReceiveCallBack(const ServerType eType, const uint16_t msg_id, NET_RECEIVE_FUNCTOR_PTR functorPtr) = 0; - virtual int AddEventCallBack(const ServerType eType, NET_EVENT_FUNCTOR_PTR functorPtr) = 0; + virtual int AddReceiveCallBack(const int eType, NET_RECEIVE_FUNCTOR_PTR functorPtr) = 0; + virtual int AddReceiveCallBack(const int eType, const uint16_t msg_id, NET_RECEIVE_FUNCTOR_PTR functorPtr) = 0; + virtual int AddEventCallBack(const int eType, NET_EVENT_FUNCTOR_PTR functorPtr) = 0; - virtual void RemoveReceiveCallBack(const ServerType eType, const uint16_t msg_id) = 0; + virtual void RemoveReceiveCallBack(const int eType, const uint16_t msg_id) = 0; //////////////////////////////////////////////////////////////////////////////// virtual void AddNode(const ConnectData &xInfo) = 0; @@ -99,9 +99,9 @@ class INetClientModule : public IModule { virtual bool SendByID(const int serverID, const uint16_t msg_id, const std::string &strData, const uint64_t uid = 0, reqid_t req_id = 0) = 0; virtual bool SendPBByID(const int serverID, const uint16_t msg_id, const google::protobuf::Message &xData, const uint64_t uid = 0, reqid_t req_id = 0) = 0; virtual void SendToAllNode(const uint16_t msg_id, const std::string &strData, const uint64_t uid = 0) = 0; - virtual void SendToAllNodeByType(const ServerType eType, const uint16_t msg_id, const std::string &strData, const uint64_t uid = 0) = 0; + virtual void SendToAllNodeByType(const int eType, const uint16_t msg_id, const std::string &strData, const uint64_t uid = 0) = 0; virtual void SendPBToAllNode(const uint16_t msg_id, const google::protobuf::Message &xData, const uint64_t uid = 0) = 0; - virtual void SendPBToAllNodeByType(const ServerType eType, const uint16_t msg_id, const google::protobuf::Message &xData, const uint64_t uid = 0) = 0; + virtual void SendPBToAllNodeByType(const int eType, const uint16_t msg_id, const google::protobuf::Message &xData, const uint64_t uid = 0) = 0; //////////////////////////////////////////////////////////////////////////////// // coroutine virtual Awaitable Request(const int serverID, const uint16_t msg_id, const std::string &data, int ack_msg_id, @@ -110,7 +110,6 @@ class INetClientModule : public IModule { const uint64_t uid = 0) = 0; virtual MapEx &GetServerList() = 0; - virtual std::shared_ptr GetServerNetInfo(const ServerType eType) = 0; virtual std::shared_ptr GetServerNetInfo(const int serverID) = 0; virtual std::shared_ptr GetServerNetInfo(const INet *pNet) = 0; diff --git a/src/squick/plugin/net/i_net_module.h b/src/squick/plugin/net/i_net_module.h index 7ba5576d..d2f2350b 100644 --- a/src/squick/plugin/net/i_net_module.h +++ b/src/squick/plugin/net/i_net_module.h @@ -18,7 +18,7 @@ struct ServerInfo { ServerInfo() { fd = 0; - info = std::shared_ptr(new rpc::Server()); + info = std::shared_ptr(new rpc::Node()); } ~ServerInfo() { fd = 0; @@ -33,7 +33,7 @@ struct ServerInfo { }; Status status = ServerInfo::Status::Unknowing; socket_t fd; - std::shared_ptr info; + std::shared_ptr info; vector listen_types; }; diff --git a/src/squick/plugin/net/net_client_module.cc b/src/squick/plugin/net/net_client_module.cc index e43da553..a997d4d9 100644 --- a/src/squick/plugin/net/net_client_module.cc +++ b/src/squick/plugin/net/net_client_module.cc @@ -10,9 +10,9 @@ NetClientModule::NetClientModule(IPluginManager *p) { bool NetClientModule::Start() { m_log_ = pm_->FindModule(); - for (int i = 0; i < ServerType::ST_MAX; ++i) { - INetClientModule::AddEventCallBack((ServerType)i, this, &NetClientModule::OnSocketEvent); - INetClientModule::AddReceiveCallBack((ServerType)i, this, &NetClientModule::OnAckHandler); + for (int i = 0; i < rpc::ST_MAX; ++i) { + INetClientModule::AddEventCallBack(i, this, &NetClientModule::OnSocketEvent); + INetClientModule::AddReceiveCallBack(i, this, &NetClientModule::OnAckHandler); } return true; } @@ -29,7 +29,7 @@ bool NetClientModule::Update() { return true; } -void NetClientModule::RemoveReceiveCallBack(const ServerType eType, const uint16_t msg_id) { +void NetClientModule::RemoveReceiveCallBack(const int eType, const uint16_t msg_id) { std::shared_ptr xCallBack = mxCallBack.GetElement(eType); if (xCallBack) { std::map>::iterator it = xCallBack->mxReceiveCallBack.find(msg_id); @@ -41,7 +41,7 @@ void NetClientModule::RemoveReceiveCallBack(const ServerType eType, const uint16 void NetClientModule::AddNode(const ConnectData &xInfo) { mxTempNetList.push_back(xInfo); } -int NetClientModule::AddReceiveCallBack(const ServerType eType, const uint16_t msg_id, NET_RECEIVE_FUNCTOR_PTR functorPtr) { +int NetClientModule::AddReceiveCallBack(const int eType, const uint16_t msg_id, NET_RECEIVE_FUNCTOR_PTR functorPtr) { std::shared_ptr xCallBack = mxCallBack.GetElement(eType); if (!xCallBack) { xCallBack = std::shared_ptr(new CallBack); @@ -61,7 +61,7 @@ int NetClientModule::AddReceiveCallBack(const ServerType eType, const uint16_t m return 0; } -int NetClientModule::AddReceiveCallBack(const ServerType eType, NET_RECEIVE_FUNCTOR_PTR functorPtr) { +int NetClientModule::AddReceiveCallBack(const int eType, NET_RECEIVE_FUNCTOR_PTR functorPtr) { std::shared_ptr xCallBack = mxCallBack.GetElement(eType); if (!xCallBack) { xCallBack = std::shared_ptr(new CallBack); @@ -73,7 +73,7 @@ int NetClientModule::AddReceiveCallBack(const ServerType eType, NET_RECEIVE_FUNC return 0; } -int NetClientModule::AddEventCallBack(const ServerType eType, NET_EVENT_FUNCTOR_PTR functorPtr) { +int NetClientModule::AddEventCallBack(const int eType, NET_EVENT_FUNCTOR_PTR functorPtr) { std::shared_ptr xCallBack = mxCallBack.GetElement(eType); if (!xCallBack) { xCallBack = std::shared_ptr(new CallBack); @@ -126,7 +126,7 @@ void NetClientModule::SendToAllNode(const uint16_t msg_id, const std::string &st } } -void NetClientModule::SendToAllNodeByType(const ServerType eType, const uint16_t msg_id, const std::string &strData, const uint64_t uid) { +void NetClientModule::SendToAllNodeByType(const int eType, const uint16_t msg_id, const std::string &strData, const uint64_t uid) { std::shared_ptr pServer = mxServerMap.First(); while (pServer) { std::shared_ptr pNetModule = pServer->net_module; @@ -171,7 +171,7 @@ void NetClientModule::SendPBToAllNode(const uint16_t msg_id, const google::proto } } -void NetClientModule::SendPBToAllNodeByType(const ServerType eType, const uint16_t msg_id, const google::protobuf::Message &xData, const uint64_t uid) { +void NetClientModule::SendPBToAllNodeByType(const int eType, const uint16_t msg_id, const google::protobuf::Message &xData, const uint64_t uid) { std::shared_ptr pServer = mxServerMap.First(); while (pServer) { std::shared_ptr pNetModule = pServer->net_module; @@ -264,15 +264,6 @@ void NetClientModule::OnAckHandler(const socket_t sock, const int msg_id, const return; } -std::shared_ptr NetClientModule::GetServerNetInfo(const ServerType eType) { - std::shared_ptr> xConnectDataMap = mxServerTypeMap.GetElement(eType); - if (xConnectDataMap) { - return xConnectDataMap->GetElementBySuitRandom(); - } - - return nullptr; -} - std::shared_ptr NetClientModule::GetServerNetInfo(const int serverID) { return mxServerMap.GetElement(serverID); } MapEx &NetClientModule::GetServerList() { return mxServerMap; } diff --git a/src/squick/plugin/net/net_client_module.h b/src/squick/plugin/net/net_client_module.h index 5c47dba2..447576e5 100644 --- a/src/squick/plugin/net/net_client_module.h +++ b/src/squick/plugin/net/net_client_module.h @@ -20,10 +20,10 @@ class NetClientModule : public INetClientModule { virtual bool Update(); virtual void AddNode(const ConnectData &xInfo); - virtual int AddReceiveCallBack(const ServerType eType, NET_RECEIVE_FUNCTOR_PTR functorPtr); - virtual int AddReceiveCallBack(const ServerType eType, const uint16_t msg_id, NET_RECEIVE_FUNCTOR_PTR functorPtr); - virtual int AddEventCallBack(const ServerType eType, NET_EVENT_FUNCTOR_PTR functorPtr); - virtual void RemoveReceiveCallBack(const ServerType eType, const uint16_t msg_id); + virtual int AddReceiveCallBack(const int eType, NET_RECEIVE_FUNCTOR_PTR functorPtr); + virtual int AddReceiveCallBack(const int eType, const uint16_t msg_id, NET_RECEIVE_FUNCTOR_PTR functorPtr); + virtual int AddEventCallBack(const int eType, NET_EVENT_FUNCTOR_PTR functorPtr); + virtual void RemoveReceiveCallBack(const int eType, const uint16_t msg_id); //////////////////////////////////////////////////////////////////////////////// virtual bool IsConnected(const int node_id) override; @@ -31,9 +31,9 @@ class NetClientModule : public INetClientModule { virtual bool SendPBByID(const int serverID, const uint16_t msg_id, const google::protobuf::Message &xData, const uint64_t uid = 0, reqid_t req_id = 0) override; virtual void SendToAllNode(const uint16_t msg_id, const std::string &strData, const uint64_t uid = 0) override; - virtual void SendToAllNodeByType(const ServerType eType, const uint16_t msg_id, const std::string &strData, const uint64_t uid = 0) override; + virtual void SendToAllNodeByType(const int eType, const uint16_t msg_id, const std::string &strData, const uint64_t uid = 0) override; virtual void SendPBToAllNode(const uint16_t msg_id, const google::protobuf::Message &xData, const uint64_t uid = 0) override; - virtual void SendPBToAllNodeByType(const ServerType eType, const uint16_t msg_id, const google::protobuf::Message &xData, const uint64_t uid = 0) override; + virtual void SendPBToAllNodeByType(const int eType, const uint16_t msg_id, const google::protobuf::Message &xData, const uint64_t uid = 0) override; // coroutine virtual Awaitable Request(const int node_id, const uint16_t msg_id, const std::string &data, int ack_msg_id, @@ -47,7 +47,6 @@ class NetClientModule : public INetClientModule { virtual MapEx &GetServerList(); - virtual std::shared_ptr GetServerNetInfo(const ServerType eType); virtual std::shared_ptr GetServerNetInfo(const int serverID); virtual std::shared_ptr GetServerNetInfo(const INet *pNet); diff --git a/src/squick/plugin/net/pb_log_module.cc b/src/squick/plugin/net/pb_log_module.cc index b7e2acae..86879d46 100644 --- a/src/squick/plugin/net/pb_log_module.cc +++ b/src/squick/plugin/net/pb_log_module.cc @@ -66,7 +66,7 @@ void PbLogModule::Log(const std::string &prefix, const int msg_id, const char *d std::string msg_name = GetMessageNameByID(msg_id); bool is_node_msg = false; - if (pm_->GetAppType() != ServerType::ST_PROXY) { + if (pm_->GetAppType() != rpc::ST_PROXY) { // inner msg is_node_msg = true; } else if (msg_name.find("rpc.NR") == 0) { diff --git a/src/squick/plugin/node/node_module.cc b/src/squick/plugin/node/node_module.cc index af587a9e..9f8c8ccd 100644 --- a/src/squick/plugin/node/node_module.cc +++ b/src/squick/plugin/node/node_module.cc @@ -43,58 +43,58 @@ inline void NodeModule::CalcWorkLoad() { last_update_time_ = now_time; } -std::string NodeModule::EnumNodeTypeToString(ServerType type) { +std::string NodeModule::EnumNodeTypeToString(rpc::NodeType type) { switch (type) { - case ServerType::ST_MASTER: + case rpc::ST_MASTER: return "master"; - case ServerType::ST_LOGIN: + case rpc::ST_LOGIN: return "login"; - case ServerType::ST_WORLD: + case rpc::ST_WORLD: return "world"; - case ServerType::ST_DB_PROXY: + case rpc::ST_DB_PROXY: return "db_proxy"; - case ServerType::ST_PROXY: + case rpc::ST_PROXY: return "proxy"; - case ServerType::ST_PLAYER: + case rpc::ST_PLAYER: return "player"; - case ServerType::ST_GAME_MGR: + case rpc::ST_GAME_MGR: return "game_mgr"; - case ServerType::ST_GAME: + case rpc::ST_GAME: return "game"; - case ServerType::ST_MICRO: + case rpc::ST_MICRO: return "micro"; - case ServerType::ST_CDN: + case rpc::ST_CDN: return "cdn"; - case ServerType::ST_WEB: + case rpc::ST_WEB: return "web"; } return ""; } -ServerType NodeModule::StringNodeTypeToEnum(const std::string &type) { +rpc::NodeType NodeModule::StringNodeTypeToEnum(const std::string &type) { if (type == "master") - return ServerType::ST_MASTER; + return rpc::ST_MASTER; else if (type == "login") - return ServerType::ST_LOGIN; + return rpc::ST_LOGIN; else if (type == "world") - return ServerType::ST_WORLD; + return rpc::ST_WORLD; else if (type == "db_proxy") - return ServerType::ST_DB_PROXY; + return rpc::ST_DB_PROXY; else if (type == "proxy") - return ServerType::ST_PROXY; + return rpc::ST_PROXY; else if (type == "player") - return ServerType::ST_PLAYER; + return rpc::ST_PLAYER; else if (type == "game_mgr") - return ServerType::ST_GAME_MGR; + return rpc::ST_GAME_MGR; else if (type == "game") - return ServerType::ST_GAME; + return rpc::ST_GAME; else if (type == "micro") - return ServerType::ST_MICRO; + return rpc::ST_MICRO; else if (type == "cdn") - return ServerType::ST_CDN; + return rpc::ST_CDN; else if (type == "web") - return ServerType::ST_WEB; - return ServerType::ST_NONE; + return rpc::ST_WEB; + return rpc::ST_NONE; } bool NodeModule::Listen() { @@ -127,10 +127,10 @@ bool NodeModule::Listen() { // Add upper server bool NodeModule::AddSubscribeNode(const vector &types) { - m_net_client_->AddEventCallBack(ST_MASTER, this, &NodeModule::OnClientSocketEvent); - m_net_client_->AddReceiveCallBack(ST_MASTER, rpc::IdNNtfNodeAdd, this, &NodeModule::OnNNtfNodeAdd); - m_net_client_->AddReceiveCallBack(ST_MASTER, rpc::IdNNtfNodeRemove, this, &NodeModule::OnNNtfNodeRemove); - m_net_client_->AddReceiveCallBack(ST_MASTER, rpc::IdNAckNodeRegister, this, &NodeModule::OnNAckNodeRegister); + m_net_client_->AddEventCallBack(rpc::ST_MASTER, this, &NodeModule::OnClientSocketEvent); + m_net_client_->AddReceiveCallBack(rpc::ST_MASTER, rpc::IdNNtfNodeAdd, this, &NodeModule::OnNNtfNodeAdd); + m_net_client_->AddReceiveCallBack(rpc::ST_MASTER, rpc::IdNNtfNodeRemove, this, &NodeModule::OnNNtfNodeRemove); + m_net_client_->AddReceiveCallBack(rpc::ST_MASTER, rpc::IdNAckNodeRegister, this, &NodeModule::OnNAckNodeRegister); bool ret = false; node_info_.listen_types = types; ConnectData s; @@ -155,14 +155,14 @@ void NodeModule::OnDynamicServerAdd(const socket_t sock, const int msg_id, const return; } for (int i = 0; i < ntf.node_list().size(); ++i) { - const rpc::Server &sd = ntf.node_list(i); + const rpc::Node &sd = ntf.node_list(i); // type ConnectData s; s.id = sd.id(); s.ip = sd.ip(); s.port = sd.port(); s.name = sd.name(); - s.type = (ServerType)sd.type(); + s.type = sd.type(); m_net_client_->AddNode(s); } } @@ -178,7 +178,7 @@ void NodeModule::UpdateState() { node_info_.info->set_connections(m_net_->GetNet()->GetConnections()); node_info_.info->set_net_client_connections(m_net_client_->GetConnections()); // Update status to master - if (pm_->GetAppType() != ST_MASTER) { + if (pm_->GetAppType() != rpc::ST_MASTER) { rpc::NNtfNodeReport req; req.set_id(pm_->GetAppID()); auto s = req.add_list(); @@ -231,7 +231,7 @@ void NodeModule::OnUpperNodeConnected(INet *pNet) { ts->state = ConnectDataState::NORMAL; // target type only master can register - if (ts->type != ST_MASTER) + if (ts->type != rpc::ST_MASTER) return; rpc::NReqNodeRegister req; @@ -269,7 +269,7 @@ void NodeModule::OnNNtfNodeAdd(const socket_t sock, const int msg_id, const char AddNodes(ntf.node_list(), true); } -bool NodeModule::AddNodes(const google::protobuf::RepeatedPtrField &list, bool from_ntf) { +bool NodeModule::AddNodes(const google::protobuf::RepeatedPtrField &list, bool from_ntf) { for (const auto &n : list) { LOG_INFO("Add node from master, is_ntf<%v> added:", from_ntf, n.name()); ConnectData s; @@ -277,7 +277,7 @@ bool NodeModule::AddNodes(const google::protobuf::RepeatedPtrField s.ip = n.ip(); s.port = n.port(); s.name = n.name(); - s.type = (ServerType)n.type(); + s.type = n.type(); m_net_client_->AddNode(s); } return true; diff --git a/src/squick/plugin/node/node_module.h b/src/squick/plugin/node/node_module.h index af774fc8..65453cd4 100644 --- a/src/squick/plugin/node/node_module.h +++ b/src/squick/plugin/node/node_module.h @@ -15,8 +15,8 @@ class NodeModule : public INodeModule { virtual bool Update() override; inline void CalcWorkLoad(); - static std::string EnumNodeTypeToString(ServerType type); - static ServerType StringNodeTypeToEnum(const std::string &type); + static std::string EnumNodeTypeToString(rpc::NodeType type); + static rpc::NodeType StringNodeTypeToEnum(const std::string &type); virtual ServerInfo &GetNodeInfo() override; @@ -47,7 +47,7 @@ class NodeModule : public INodeModule { // Add node ntf void OnNNtfNodeAdd(const socket_t sock, const int msg_id, const char *msg, const uint32_t len); - bool AddNodes(const google::protobuf::RepeatedPtrField &list, bool from_ntf = false); + bool AddNodes(const google::protobuf::RepeatedPtrField &list, bool from_ntf = false); // Add node ntf void OnNNtfNodeRemove(const socket_t sock, const int msg_id, const char *msg, const uint32_t len); diff --git a/src/tools/sqkcli/core/tester_module.cc b/src/tools/sqkcli/core/tester_module.cc index 46463f96..d8c6275e 100644 --- a/src/tools/sqkcli/core/tester_module.cc +++ b/src/tools/sqkcli/core/tester_module.cc @@ -37,12 +37,12 @@ bool TesterModule::AfterStart() { void TesterModule::TestProxyTransferSpeed_Init() { std::cout << "Test proxy Transfer speed!\n"; - m_net_client_->AddReceiveCallBack(ServerType::ST_PROXY, rpc::TestRPC::ACK_TEST_PROXY, this, &TesterModule::TestProxyTransferSpeed_Ack); - m_net_client_->AddEventCallBack(ServerType::ST_PROXY, this, &TesterModule::OnClientSocketEvent); + m_net_client_->AddReceiveCallBack(rpc::ST_PROXY, rpc::TestRPC::ACK_TEST_PROXY, this, &TesterModule::TestProxyTransferSpeed_Ack); + m_net_client_->AddEventCallBack(rpc::ST_PROXY, this, &TesterModule::OnClientSocketEvent); ConnectData s; s.id = 1; // Just for test - s.type = ServerType::ST_PROXY; + s.type = rpc::ST_PROXY; s.ip = pm_->GetArg("ip=", "127.0.0.1"); s.port = pm_->GetArg("port=", 10501); s.name = "test"; @@ -55,7 +55,7 @@ void TesterModule::TestProxyTransferSpeed_Req() { test.set_index(test_req_index_); test.set_data(test_req_data_); test.set_req_time(SquickGetTimeMSEx()); - m_net_client_->SendPBToAllNodeByType(ServerType::ST_PROXY, rpc::TestRPC::REQ_TEST_PROXY, test, 0); + m_net_client_->SendPBToAllNodeByType(rpc::ST_PROXY, rpc::TestRPC::REQ_TEST_PROXY, test, 0); test_req_index_++; test_req_data_ = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; } diff --git a/src/tutorial/t6_rpc/rpc_module.cc b/src/tutorial/t6_rpc/rpc_module.cc index 5a0504fe..1d39a3dd 100644 --- a/src/tutorial/t6_rpc/rpc_module.cc +++ b/src/tutorial/t6_rpc/rpc_module.cc @@ -3,7 +3,7 @@ namespace tutorial { bool SimpleModule::Start() { m_net_client_ = pm_->FindModule(); - m_net_client_->AddReceiveCallBack(ServerType::ST_GAME, 1123, this, &SimpleModule::OnRecivedMsg); + m_net_client_->AddReceiveCallBack(rpc::ST_GAME, 1123, this, &SimpleModule::OnRecivedMsg); dout << "RPC Start ...\n"; return true; }