diff --git a/resource/script/multi_start.bat b/resource/script/multi_start.bat index fe41e6ac..565ee542 100644 --- a/resource/script/multi_start.bat +++ b/resource/script/multi_start.bat @@ -6,19 +6,10 @@ rem Description: Start all servers script cd bin -start cmd /c " squick type=master id=1 " -start cmd /c " squick type=login id=2 " -start cmd /c " squick type=world id=100 " -start cmd /c " squick type=world id=101 " -start cmd /c " squick type=db_proxy id=300 " -start cmd /c " squick type=db_proxy id=301 " - -start cmd /c " squick type=lobby id=1000 " -start cmd /c " squick type=lobby id=1001 " -start cmd /c " squick type=lobby id=1002 " - -rem start cmd /c " squick type=game_mgr id=2000 " - -start cmd /c " squick type=proxy id=500 " -start cmd /c " squick type=proxy id=501 " -start cmd /c " squick type=proxy id=502 " \ No newline at end of file +start cmd /c " squick type=master id=1 area=0 ip=127.0.0.1 port=10001 web_port=8888" +start cmd /c " squick type=world id=100 area=0 ip=127.0.0.1 port=10101 master_ip=127.0.0.1 master_port=10001" +start cmd /c " squick type=db_proxy id=300 area=0 ip=127.0.0.1 port=10201 master_ip=127.0.0.1 master_port=10001" +start cmd /c " squick type=login id=2 area=0 ip=127.0.0.1 port=10301 web_port=80 master_ip=127.0.0.1 master_port=10001" +start cmd /c " squick type=lobby id=1000 area=0 ip=127.0.0.1 port=10401 master_ip=127.0.0.1 master_port=10001" +start cmd /c " squick type=lobby id=1001 area=0 ip=127.0.0.1 port=10402 master_ip=127.0.0.1 master_port=10001" +start cmd /c " squick type=proxy id=500 area=0 ip=127.0.0.1 port=10501 master_ip=127.0.0.1 master_port=10001" \ No newline at end of file diff --git a/src/main.cc b/src/main.cc index 6eb24bcf..c772e4bb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -46,28 +46,15 @@ void PrintLogo() { void DefaultStartUp(std::string strArgvList, std::vector> &serverList) { serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=master id=1 area=0 ip=127.0.0.1 port=10001 web_port=8888"))); - serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=world id=100 area=0 ip=127.0.0.1 port=10101 master=127.0.0.1:10001"))); - //serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=world id=101"))); // 区服2 - serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=db_proxy id=300 area=0 ip=127.0.0.1 port=10201 master=127.0.0.1:10001"))); - - //serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=db_proxy id=301"))); // 区服2 - - serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=login id=2 area=0 ip=127.0.0.1 port=10301 web_port=80 master=127.0.0.1:10001"))); + serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=world id=100 area=0 ip=127.0.0.1 port=10101 master_ip=127.0.0.1 master_port=10001"))); + serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=db_proxy id=300 area=0 ip=127.0.0.1 port=10201 master_ip=127.0.0.1 master_port=10001"))); + serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=login id=2 area=0 ip=127.0.0.1 port=10301 web_port=80 master_ip=127.0.0.1 master_port=10001"))); // Lobby - serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=lobby id=1000 area=0 ip=127.0.0.1 port=10401 master=127.0.0.1:10001"))); - serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=lobby id=1001 area=0 ip=127.0.0.1 port=10402 master=127.0.0.1:10001"))); - //serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=lobby id=1002"))); - - // Game - //serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=game id=3000"))); - //serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=game id=3001"))); - //serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=game_mgr id=2000"))); - - serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=proxy id=500 area=0 ip=127.0.0.1 port=10501 master=127.0.0.1:10001"))); - //serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=proxy id=501"))); + serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=lobby id=1000 area=0 ip=127.0.0.1 port=10401 master_ip=127.0.0.1 master_port=10001"))); + serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=lobby id=1001 area=0 ip=127.0.0.1 port=10402 master_ip=127.0.0.1 master_port=10001"))); + serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=proxy id=500 area=0 ip=127.0.0.1 port=10501 master_ip=127.0.0.1 master_port=10001"))); - //serverList.push_back(std::shared_ptr(new PluginServer(strArgvList + " type=proxy id=502"))); // 区服2 } void TutorialStartUp(std::string strArgvList, std::vector>& serverList) { diff --git a/src/node/db_proxy/node/node_module.cc b/src/node/db_proxy/node/node_module.cc index a846acc0..50b52554 100644 --- a/src/node/db_proxy/node/node_module.cc +++ b/src/node/db_proxy/node/node_module.cc @@ -8,7 +8,7 @@ namespace db_proxy::node { bool NodeModule::AfterStart() { Listen(); - AddServer(ServerType::ST_WORLD); + ConnectToMaster(); return true; } diff --git a/src/node/lobby/node/node_module.cc b/src/node/lobby/node/node_module.cc index 97e031b4..cd68fab0 100644 --- a/src/node/lobby/node/node_module.cc +++ b/src/node/lobby/node/node_module.cc @@ -4,8 +4,10 @@ namespace lobby::node { bool NodeModule::AfterStart() { Listen(); - AddServer(ServerType::ST_WORLD); - AddServer(ServerType::ST_DB_PROXY); + //AddServer(ServerType::ST_WORLD); + //AddServer(ServerType::ST_DB_PROXY); + + ConnectToMaster(); return true; } diff --git a/src/node/login/node/node_module.cc b/src/node/login/node/node_module.cc index 5396a0c1..8c5ef90e 100644 --- a/src/node/login/node/node_module.cc +++ b/src/node/login/node/node_module.cc @@ -11,7 +11,7 @@ bool NodeModule::BeforeDestory() { return true; } bool NodeModule::AfterStart() { m_net_->AddReceiveCallBack(this, &NodeModule::InvalidMessage); Listen(); - AddServer(ServerType::ST_MASTER); + ConnectToMaster(); return true; } diff --git a/src/node/proxy/node/node_module.cc b/src/node/proxy/node/node_module.cc index ca2b36dc..002bd785 100644 --- a/src/node/proxy/node/node_module.cc +++ b/src/node/proxy/node/node_module.cc @@ -11,9 +11,7 @@ bool NodeModule::AfterStart() { m_net_client_->AddReceiveCallBack(ServerType::ST_LOBBY, this, &NodeModule::Transport); m_net_client_->AddReceiveCallBack(ServerType::ST_LOGIN, rpc::LoginRPC::ACK_PROXY_CONNECT_VERIFY, this, &NodeModule::OnAckProxyConnectVerify); m_net_client_->AddReceiveCallBack(ServerType::ST_LOBBY, rpc::PlayerEventRPC::PLAYER_BIND_EVENT, this, &NodeModule::PlayerBindEvent); - AddServer(ServerType::ST_LOBBY); - AddServer(ServerType::ST_LOGIN); - AddServer(ServerType::ST_WORLD); + ConnectToMaster(); // ws diff --git a/src/node/world/node/node_module.cc b/src/node/world/node/node_module.cc index e3371913..7cb0ff3f 100644 --- a/src/node/world/node/node_module.cc +++ b/src/node/world/node/node_module.cc @@ -5,8 +5,7 @@ namespace world::node { bool NodeModule::AfterStart() { Listen(); - - AddServer(ServerType::ST_MASTER); + ConnectToMaster(); return true; } diff --git a/src/squick/imodule/i_node_module.h b/src/squick/imodule/i_node_module.h index 23159f42..e6da3b48 100644 --- a/src/squick/imodule/i_node_module.h +++ b/src/squick/imodule/i_node_module.h @@ -54,7 +54,6 @@ class INodeBaseModule : public IModule { } virtual bool Listen() { - m_net_->AddReceiveCallBack(rpc::ServerRPC::REQ_REGISTER, this, &INodeBaseModule::OnReqRegister); m_net_->AddReceiveCallBack(rpc::ServerRPC::REQ_UNREGISTER, this, &INodeBaseModule::OnServerUnRegistered); m_net_->AddReceiveCallBack(rpc::ServerRPC::REQ_REPORT, this, &INodeBaseModule::OnReqServerReport); @@ -64,21 +63,20 @@ class INodeBaseModule : public IModule { ServerInfo s; s.info->set_id(pm_->GetArg("id=", 0)); - //s.info->set_key("key"); std::string name = pm_->GetArg("type=", "squick_node") + pm_->GetArg("id=", "0"); s.info->set_type(StringNodeTypeToEnum(pm_->GetArg("type=", "squick_node"))); s.info->set_port(pm_->GetArg("port=", 10000)); - //s.info->set_max_online(m_element_->GetPropertyInt32(strId, excel::Server::MaxOnline())); - //s.info->set_cpu_count(m_element_->GetPropertyInt32(strId, excel::Server::CpuCount())); + s.info->set_name(name); s.info->set_ip(pm_->GetArg("ip=", "127.0.0.1")); s.info->set_public_ip(pm_->GetArg("public_ip=", "127.0.0.1")); s.info->set_area(pm_->GetArg("area=", 0)); - //s.info->set_cpu_count(m_element_->GetPropertyInt32(strId, excel::Server::CpuCount())); - s.type = ServerInfo::Type::Self; s.info->set_update_time(SquickGetTimeS()); + s.info->set_max_online(10000); + s.info->set_cpu_count(8); pm_->SetAppType(s.info->type()); pm_->SetArea(s.info->area()); + servers_[pm_->GetAppID()] = s; int nRet = m_net_->Startialization(s.info->max_online(), s.info->port(), s.info->cpu_count()); @@ -98,52 +96,34 @@ class INodeBaseModule : public IModule { } // Add upper server - bool AddServer(ServerType type) { - m_net_client_->AddEventCallBack(type, this, &INodeBaseModule::OnClientSocketEvent); - m_net_client_->AddReceiveCallBack(type, rpc::ServerRPC::SERVER_ADD, this, &INodeBaseModule::OnDynamicServerAdd); - m_net_client_->AddReceiveCallBack(type, rpc::ServerRPC::ACK_REGISTER, this, &INodeBaseModule::OnAckRegister); - m_net_client_->AddReceiveCallBack(type, rpc::ServerRPC::ACK_REPORT, this, &INodeBaseModule::OnAckServerReport); + bool ConnectToMaster() { + m_net_client_->AddEventCallBack(ST_MASTER, this, &INodeBaseModule::OnClientSocketEvent); + m_net_client_->AddReceiveCallBack(ST_MASTER, rpc::ServerRPC::SERVER_ADD, this, &INodeBaseModule::OnDynamicServerAdd); + m_net_client_->AddReceiveCallBack(ST_MASTER, rpc::ServerRPC::ACK_REGISTER, this, &INodeBaseModule::OnAckRegister); + m_net_client_->AddReceiveCallBack(ST_MASTER, rpc::ServerRPC::ACK_REPORT, this, &INodeBaseModule::OnAckServerReport); m_net_client_->ExpandBufferSize(); bool ret = false; - std::shared_ptr config = m_class_->GetElement(excel::Server::ThisName()); - if (config) { - const std::vector& list = config->GetIDList(); - const int cur_area = pm_->GetArea(); - for (auto k : list) { - const int server_type = m_element_->GetPropertyInt32(k, excel::Server::Type()); - const int area = m_element_->GetPropertyInt32(k, excel::Server::Area()); - - if (server_type == type) { - // 增加同一区服的,如果是Master或Login,不用校验区服 - if (type == ServerType::ST_MASTER || type == ServerType::ST_LOGIN || area == cur_area) { - int id = m_element_->GetPropertyInt32(k, excel::Server::ServerID()); - ServerInfo info; - - info.type = ServerInfo::Type::Parrent; // 标识该节点为父节点 - info.status = ServerInfo::Status::Connecting; - info.info->set_port(m_element_->GetPropertyInt32(k, excel::Server::Port())); - info.info->set_name(m_element_->GetPropertyString(k, excel::Server::ID())); - info.info->set_ip(m_element_->GetPropertyString(k, excel::Server::IP())); - info.info->set_id(id); - servers_[id] = info; - - ConnectData s; - s.id = id; - s.type = (ServerType)server_type; - s.ip = info.info->ip(); - s.port = info.info->port(); - s.name = k; - - std::ostringstream log; - log << "Node Connect to " << s.name << " host " << s.ip << ":" << s.port << " cur_area: " << cur_area << " target area:" << area << std::endl; - m_log_->LogDebug(NULL_OBJECT, log, __FUNCTION__, __LINE__); - m_net_client_->AddServer(s); - ret = true; - } - } - } - } - return ret; + + // 增加同一区服的,如果是Master或Login,不用校验区服 + int default_id = 1; + ServerInfo info; + info.status = ServerInfo::Status::Connecting; + info.info->set_port(pm_->GetArg("master_port=", 10001)); + info.info->set_name("master"); + info.info->set_ip(pm_->GetArg("master_ip=", "127.0.0.1")); + info.info->set_id(default_id); + servers_[default_id] = info; + ConnectData s; + s.id = default_id; + s.type = StringNodeTypeToEnum("master"); + s.ip = info.info->ip(); + s.port = info.info->port(); + s.name = "master"; + std::ostringstream log; + log << "Node Connect to " << s.name << " host " << s.ip << ":" << s.port << " cur_area: " << pm_->GetArg("area=", 0) << std::endl; + m_log_->LogDebug(NULL_OBJECT, log, __FUNCTION__, __LINE__); + m_net_client_->AddNode(s); + return true; } void InvalidMessage(const socket_t sock, const int msg_id, const char* msg, const uint32_t len) { printf("Net || umsg_id=%d\n", msg_id); } @@ -168,14 +148,9 @@ class INodeBaseModule : public IModule { s.name = sd.name(); s.work_load = sd.cpu_count(); s.type = (ServerType)sd.type(); - m_net_client_->AddServer(s); + m_net_client_->AddNode(s); } } - - - - - //////////////////////////// PRIVATE //////////////////////////// private: // 热加载配置文件 @@ -187,11 +162,9 @@ class INodeBaseModule : public IModule { } - virtual void OnServerRefreshed(const socket_t sock, const int msg_id, const char *msg, const uint32_t len) { - } - // Report to upper server void ReqServerReport() { + dout << "report ...\n"; rpc::ReqReport req; req.set_id(pm_->GetAppID()); // 更新自己的时间 @@ -199,27 +172,6 @@ class INodeBaseModule : public IModule { iter->second.info->set_update_time(SquickGetTimeS()); // 将下游服务和自己全部注册更新到上游 - for (auto sv : servers_) { - if (sv.second.info->area() == pm_->GetArea()) { - if (sv.second.type == ServerInfo::Type::Child || sv.second.type != ServerInfo::Type::Parrent) { - auto s = req.add_list(); - *s = *sv.second.info.get(); - } - } - } - for (auto sv : servers_) { - //m_log_->LogWarning("ReqServerReport to " + to_string(sv.second.info->id())); - if (sv.second.type == ServerInfo::Type::Parrent && sv.second.status == ServerInfo::Status::Connected) { - if (sv.second.info->area() == pm_->GetArea() || - sv.second.info->type() == ServerType::ST_LOGIN || - sv.second.info->type() == ServerType::ST_MASTER ) { - ostringstream s; - //s << "ReqServerReport to " << sv.second.info->id() << " push: " << req.list().size(); - //m_log_->LogWarning(s); - m_net_client_->SendToServerByPB(sv.second.info->id(), rpc::REQ_REPORT, req); - } - } - } } virtual void OnReqServerReport(const socket_t sock, const int msg_id, const char *msg, const uint32_t len) { @@ -248,7 +200,6 @@ class INodeBaseModule : public IModule { ServerInfo info; info.fd = 0; info.status = ServerInfo::Status::Unknowing; - info.type = ServerInfo::Type::Unknowing; *info.info = s; servers_[s.id()] = info; } @@ -278,8 +229,8 @@ class INodeBaseModule : public IModule { } ostringstream s; - //s << "Ack ServerReport from: " << guid.ToString() << " pulled: " << ack.list().size(); - //m_log_->LogDebug(s); + s << "Ack ServerReport from: " << guid << " pulled: " << ack.list().size(); + m_log_->LogDebug(s); if (ack.code() == 0) { for (auto s : ack.list()) { @@ -296,7 +247,6 @@ class INodeBaseModule : public IModule { ServerInfo info; info.fd = 0; info.status = ServerInfo::Status::Unknowing; - info.type = ServerInfo::Type::Unknowing; *info.info = s; servers_[s.id()] = info; } @@ -343,7 +293,6 @@ class INodeBaseModule : public IModule { } } - // 向连接的服务注册自己 void ReqRegister(INet* pNet) { rpc::ReqRegisterServer req; @@ -356,35 +305,15 @@ class INodeBaseModule : public IModule { return; } req.set_key("no passowrd"); - // 取出即将连接服务器的密钥 - std::shared_ptr config = m_class_->GetElement(excel::Server::ThisName()); - if (config) { - const std::vector& idx_list = config->GetIDList(); - - for (auto& idx : idx_list) { - int id = m_element_->GetPropertyInt32(idx, excel::Server::ServerID()); - if (id == ts->id) { - string key = m_element_->GetPropertyString(idx, excel::Server::Key()); - req.set_key(key); - break; - } - } - } - - // 将下游服务和自己全部注册到上游 - for (auto sv : servers_) { - if ( (sv.second.type == ServerInfo::Type::Child || sv.second.type == ServerInfo::Type::Self)&& - sv.second.status == ServerInfo::Status::Connected && - sv.second.info->area() == pm_->GetArea()) { - auto s = req.add_list(); - *s = *sv.second.info.get(); - } - } - + // 将自己注册到上游 + auto s = req.add_list(); + *s = *servers_[pm_->GetAppID()].info.get(); + dout << "register: " << s->id() << endl; m_net_client_->SendToServerByPB(ts->id, rpc::ServerRPC::REQ_REGISTER, req); - //dout << pm_->GetAppName() << " 请求连接 " << ts->name << "\n"; - //m_log_->LogInfo(Guid(0, pm_->GetAppID()), s->name(), "Register"); + + dout << pm_->GetAppName() << " 请求连接 " << ts->name << " target_id" << ts->id << "\n"; + m_log_->LogInfo(Guid(0, pm_->GetAppID()), ts->name, "Register"); } @@ -397,13 +326,6 @@ class INodeBaseModule : public IModule { rpc::AckRegisterServer ack; do { auto& cs = servers_[pm_->GetAppID()]; - // 验证key - if (req.key() != cs.info->key()) { - dout << " 校验key失败: req key" << req.key() << " our key" << cs.info->key() << "\n"; - ack.set_code(1); - break; - } - ack.set_code(0); for (auto s : req.list()) { if (s.id() == pm_->GetAppID()) { // 排除自己 @@ -422,7 +344,6 @@ class INodeBaseModule : public IModule { auto iter = servers_.find(req.id()); if (iter != servers_.end()) { iter->second.status = ServerInfo::Status::Connected; - iter->second.type = ServerInfo::Type::Child; } int area = servers_[req.id()].info->area(); @@ -454,14 +375,11 @@ class INodeBaseModule : public IModule { ServerInfo info; info.fd = 0; info.status = ServerInfo::Status::Unknowing; - info.type = ServerInfo::Type::Unknowing; *info.info = s; servers_[s.id()] = info; } else { - if (iter->second.type == ServerInfo::Type::Parrent) { - iter->second.status = ServerInfo::Status::Connected; - } + iter->second.status = ServerInfo::Status::Connected; *iter->second.info = s; } } @@ -488,10 +406,6 @@ class INodeBaseModule : public IModule { m_log_->LogInfo(Guid(0, s.id()), s.name(), " UnRegistered"); } } - - virtual void OnReqManager(const socket_t sock, const int msg_id, const char* msg, const uint32_t len) { - - } public: virtual int GetLoadBanlanceNode(ServerType type) { diff --git a/src/squick/plugin/net/i_net_client_module.h b/src/squick/plugin/net/i_net_client_module.h index 86637eb5..ad258233 100644 --- a/src/squick/plugin/net/i_net_client_module.h +++ b/src/squick/plugin/net/i_net_client_module.h @@ -81,8 +81,8 @@ class INetClientModule : public IModule { virtual void RemoveReceiveCallBack(const ServerType eType, const uint16_t msg_id) = 0; //////////////////////////////////////////////////////////////////////////////// - virtual void AddServer(const ConnectData& xInfo) = 0; - virtual unsigned int ExpandBufferSize(const unsigned int size = 1024 * 1024 * 20) = 0; + virtual void AddNode(const ConnectData& xInfo) = 0; + virtual unsigned int ExpandBufferSize(const unsigned int size = 1024 * 1024) = 0; //////////////////////////////////////////////////////////////////////////////// virtual void SendByServerID(const int serverID, const uint16_t msg_id, const std::string& strData) = 0; diff --git a/src/squick/plugin/net/i_net_module.h b/src/squick/plugin/net/i_net_module.h index 778e2c40..050e00de 100644 --- a/src/squick/plugin/net/i_net_module.h +++ b/src/squick/plugin/net/i_net_module.h @@ -55,12 +55,6 @@ struct ServerInfo { fd = 0; info = NULL; } - enum class Type { - Unknowing, - Child, - Parrent, - Self, - }; enum class Status { Unknowing, @@ -68,7 +62,6 @@ struct ServerInfo { Connected, Disconnected, }; - Type type = ServerInfo::Type::Child; Status status = ServerInfo::Status::Unknowing; socket_t fd; std::shared_ptr info; diff --git a/src/squick/plugin/net/net.cc b/src/squick/plugin/net/net.cc index 41400c0a..2031e545 100644 --- a/src/squick/plugin/net/net.cc +++ b/src/squick/plugin/net/net.cc @@ -34,7 +34,7 @@ void Net::conn_writecb(struct bufferevent *bev, void *user_data) { void Net::conn_eventcb(struct bufferevent *bev, short events, void *user_data) { NetObject *pObject = (NetObject *)user_data; Net *pNet = (Net *)pObject->GetNet(); - //dout << "网络事件 : Thread ID = " << std::this_thread::get_id() << " FD = " << pObject->GetRealFD() << " Event ID =" << events; + //dout << "网络事件 : Thread ID = " << std::this_thread::get_id() << " FD = " << pObject->GetRealFD() << " Event ID =" << events // << std::endl; if (events & BEV_EVENT_CONNECTED) { // must to set it's state before the "EventCB" functional be called[maybe user will send msg in the callback function] @@ -249,7 +249,6 @@ bool Net::SendMsg(const char *msg, const size_t len, const socket_t sock) { bufferevent *bev = (bufferevent *)pNetObject->GetUserData(); if (NULL != bev) { bufferevent_write(bev, msg, len); - mnSendMsgTotal++; return true; } @@ -285,7 +284,7 @@ bool Net::CloseNetObject(const socket_t sock) { // 拆包 bool Net::Dismantle(NetObject *pObject) { bool bNeedDismantle = false; - + int len = pObject->GetBuffLen(); if (len >= IMsgHead::SQUICK_Head::SQUICK_HEAD_LENGTH) { rpcHead xHead; diff --git a/src/squick/plugin/net/net_client_module.cc b/src/squick/plugin/net/net_client_module.cc index eef54fd6..76935a4b 100644 --- a/src/squick/plugin/net/net_client_module.cc +++ b/src/squick/plugin/net/net_client_module.cc @@ -49,7 +49,7 @@ void NetClientModule::RemoveReceiveCallBack(const ServerType eType, const uint16 } } -void NetClientModule::AddServer(const ConnectData &xInfo) { mxTempNetList.push_back(xInfo); } +void NetClientModule::AddNode(const ConnectData &xInfo) { mxTempNetList.push_back(xInfo); } unsigned int NetClientModule::ExpandBufferSize(const unsigned int size) { if (size > 0) { diff --git a/src/squick/plugin/net/net_client_module.h b/src/squick/plugin/net/net_client_module.h index 9f8774d9..20c8c4f9 100644 --- a/src/squick/plugin/net/net_client_module.h +++ b/src/squick/plugin/net/net_client_module.h @@ -24,7 +24,7 @@ class NetClientModule : public INetClientModule { virtual bool Update(); - virtual void AddServer(const ConnectData &xInfo); + virtual void AddNode(const ConnectData &xInfo); virtual unsigned int ExpandBufferSize(const unsigned int size = 1024 * 1024 * 20) override; diff --git a/src/squick/plugin/net/net_module.cc b/src/squick/plugin/net/net_module.cc index a780164b..8e07b7fb 100644 --- a/src/squick/plugin/net/net_module.cc +++ b/src/squick/plugin/net/net_module.cc @@ -292,8 +292,8 @@ bool NetModule::SendMsgPB(const uint16_t msg_id, const std::string &strData, con INet *NetModule::GetNet() { return m_pNet; } void NetModule::OnReceiveNetPack(const socket_t sock, const int msg_id, const char *msg, const uint32_t len) { - //m_log_->LogInfo(pm_->GetAppName() + std::to_string(pm_->GetAppID()) + " NetModule::OnReceiveNetPack " + - //std::to_string(msg_id), __FILE__, __LINE__); + m_log_->LogInfo(pm_->GetAppName() + std::to_string(pm_->GetAppID()) + " NetModule::OnReceiveNetPack " + + std::to_string(msg_id), __FILE__, __LINE__); Performance performance; diff --git a/src/tools/sqkcli/core/tester_module.cc b/src/tools/sqkcli/core/tester_module.cc index 93c59ac9..cc6d4163 100644 --- a/src/tools/sqkcli/core/tester_module.cc +++ b/src/tools/sqkcli/core/tester_module.cc @@ -8,7 +8,6 @@ bool TesterModule::Start() { std::cout << "Squick Tester\n"; - m_net_ = pm_->FindModule(); m_log_ = pm_->FindModule(); m_element_ = pm_->FindModule(); @@ -104,7 +103,7 @@ bool TesterModule::AddServer(ServerType type) { s.ip = ip; s.port = nPort; s.name = strId; - m_net_client_->AddServer(s); + m_net_client_->AddNode(s); return true; } }