int NFCLoginNet_ServerModule::OnSelectWorldProcess( const NFIPacket& msg ) { NFIDENTID nPlayerID; NFMsg::ReqConnectWorld xMsg; if (!RecivePB(msg, xMsg, nPlayerID)) { return 0; } NetObject* pNetObject = GetNet()->GetNetObject(msg.GetFd()); if (!pNetObject) { return 0; } //没登录过 if (pNetObject->GetConnectKeyState() <= 0) { return 0; } NFCDataList val; val << xMsg.world_id() << pNetObject->GetClientID() << pPluginManager->AppID() << pNetObject->GetAccount(); m_pEventProcessModule->DoEvent(NFIDENTID(), NFED_ON_CLIENT_SELECT_SERVER, val); return 0; }
int NFCWorldToMasterModule::OnSelectServerProcess(const NFIPacket& msg) { NFIDENTID nPlayerID; NFMsg::ReqConnectWorld xMsg; if (!NFINetModule::RecivePB(msg, xMsg, nPlayerID)) { return 0; } NFCDataList var; var << xMsg.world_id() << NFINetModule::PBToNF(xMsg.sender()) << xMsg.login_id() << xMsg.account(); m_pEventProcessModule->DoEvent(NFIDENTID(), NFED_ON_CLIENT_SELECT_SERVER, var); return 0; }
void NFCMasterNet_ServerModule::OnSelectWorldProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ReqConnectWorld xMsg; if (!m_pNetModule->ReceivePB( nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } NF_SHARE_PTR<ServerData> pServerData = mWorldMap.GetElement(xMsg.world_id()); if (!pServerData) { return; } m_pNetModule->SendMsgPB(NFMsg::EGameMsgID::EGMI_REQ_CONNECT_WORLD, xMsg, pServerData->nFD); }
void NFCWorldToMasterModule::OnSelectServerProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ReqConnectWorld xMsg; if (!NFINetModule::ReceivePB(nSockIndex, nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } NF_SHARE_PTR<ServerData> xServerData = m_pWorldNet_ServerModule->GetSuitProxyForEnter(); if (xServerData) { NFMsg::AckConnectWorldResult xData; xData.set_world_id(xMsg.world_id()); xData.mutable_sender()->CopyFrom(xMsg.sender()); xData.set_login_id(xMsg.login_id()); xData.set_account(xMsg.account()); xData.set_world_ip(xServerData->pData->server_ip()); xData.set_world_port(xServerData->pData->server_port()); xData.set_world_key(xMsg.account()); m_pWorldNet_ServerModule->GetNetModule()->SendMsgPB(NFMsg::EGMI_ACK_CONNECT_WORLD, xData, xServerData->nFD); m_pNetClientModule->SendSuitByPB(xMsg.account(), NFMsg::EGMI_ACK_CONNECT_WORLD, xData); } }
void NFCLoginNet_ServerModule::OnSelectWorldProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ReqConnectWorld xMsg; if (!m_pNetModule->ReceivePB(nSockIndex, nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } NetObject* pNetObject = m_pNetModule->GetNet()->GetNetObject(nSockIndex); if (!pNetObject) { return; } //没登录过 if (pNetObject->GetConnectKeyState() <= 0) { return; } NFMsg::ReqConnectWorld xData; xData.set_world_id(xMsg.world_id()); xData.set_login_id(pPluginManager->AppID()); xData.mutable_sender()->CopyFrom(NFINetModule::NFToPB(pNetObject->GetClientID())); xData.set_account(pNetObject->GetAccount()); m_pLoginToMasterModule->GetClusterModule()->SendSuitByPB(pNetObject->GetAccount(), NFMsg::EGameMsgID::EGMI_REQ_CONNECT_WORLD, xData);//here has a problem to be solve }
int NFCMasterNet_ServerModule::OnSelectWorldProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ReqConnectWorld xMsg; if (!RecivePB(nSockIndex, nMsgID, msg, nLen, xMsg, nPlayerID)) { return 0; } NF_SHARE_PTR<ServerData> pServerData = mWorldMap.GetElement(xMsg.world_id()); if (!pServerData.get()) { return 0; } //转发送到世界服务器 SendMsgPB(NFMsg::EGameMsgID::EGMI_REQ_CONNECT_WORLD, xMsg, pServerData->nFD); return 0; }
bool NFCLoginNet_HttpServerModule::OnWorldSelect(const NFHttpRequest & req) { std::string strResponse; NFIResponse xResponse; std::string user = GetUserID(req); NFRequestSelectWorld xRequestSelectWorld; ajson::load_from_buff(xRequestSelectWorld, req.body.c_str()); if (xRequestSelectWorld.id == 0) { xResponse.code = NFIResponse::ResponseType::RES_TYPE_FAILED; ajson::string_stream ss; ajson::save_to(ss, xResponse); strResponse = ss.str(); return m_pHttpNetModule->ResponseMsg(req, strResponse, NFWebStatus::WEB_OK); } NFMsg::ReqConnectWorld xData; xData.set_world_id(xRequestSelectWorld.id); xData.set_login_id(pPluginManager->GetAppID()); xData.mutable_sender()->CopyFrom(NFINetModule::NFToPB(NFGUID())); xData.set_account(user); m_pNetClientModule->SendSuitByPB(NF_SERVER_TYPES::NF_ST_MASTER, user, NFMsg::EGameMsgID::EGMI_REQ_CONNECT_WORLD, xData); /* while (true) { YieldCo(); if () { break; } } */ return m_pHttpNetModule->ResponseMsg(req, strResponse, NFWebStatus::WEB_OK); }