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; }
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 }
void NFCLoginLogicModule::OnLoginProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ReqAccountLogin xMsg; if (!m_pNetModule->ReceivePB( nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } NetObject* pNetObject = m_pNetModule->GetNet()->GetNetObject(nSockIndex); if (pNetObject) { if (pNetObject->GetConnectKeyState() == 0) { if (!m_pAccountRedisModule->ExistAccount(xMsg.account())) { m_pAccountRedisModule->AddAccount(xMsg.account(), xMsg.password()); } int nState = m_pAccountRedisModule->VerifyAccount(xMsg.account(), xMsg.password()); if (0 != nState) { std::ostringstream strLog; strLog << "Check password failed, Account = " << xMsg.account() << " Password = "******"Login successed :", xMsg.account().c_str()); } } }
void NFCProxyServerNet_ServerModule::OnOtherMessage(const int nSockIndex, const int nMsgID, const char * msg, const uint32_t nLen) { NFMsg::MsgBase xMsg; if (!xMsg.ParseFromArray(msg, nLen)) { char szData[MAX_PATH] = { 0 }; sprintf(szData, "Parse Message Failed from Packet to MsgBase, MessageID: %d\n", nMsgID); return; } NetObject* pNetObject = m_pNetModule->GetNet()->GetNetObject(nSockIndex); if (!pNetObject || pNetObject->GetConnectKeyState() <= 0 || pNetObject->GetGameID() <= 0) { //state error return; } if (xMsg.has_hash_ident()) { //special for distributed if (!pNetObject->GetHashIdentID().IsNull()) { NFCMachineNode xNode; if (mxConsistentHash.GetSuitNode(pNetObject->GetHashIdentID().ToString(), xNode)) { m_pProxyServerToGameModule->GetClusterModule()->SendByServerID(xNode.GetDataID(), nMsgID, msg, nLen); } } else { NFGUID xHashIdent = NFINetModule::PBToNF(xMsg.hash_ident()); NFCMachineNode xNode; if (mxConsistentHash.GetSuitNode(xHashIdent.ToString(), xNode)) { m_pProxyServerToGameModule->GetClusterModule()->SendByServerID(xNode.GetDataID(), nMsgID, msg, nLen); } } } else { m_pProxyServerToGameModule->GetClusterModule()->SendByServerID(pNetObject->GetGameID(), nMsgID, msg, nLen); } }
void NFCProxyServerNet_ServerModule::OnReqEnterGameServer(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { //在没有正式进入游戏之前,nPlayerID都是FD NFGUID nPlayerID; NFMsg::ReqEnterGameServer xData; if (!m_pNetModule->ReceivePB(nSockIndex, nMsgID, msg, nLen, xData, nPlayerID)) { return; } NF_SHARE_PTR<ConnectData> pServerData = m_pProxyServerToGameModule->GetClusterModule()->GetServerNetInfo(xData.game_id()); if (pServerData && ConnectDataState::NORMAL == pServerData->eState) { //数据匹配 NetObject* pNetObject = m_pNetModule->GetNet()->GetNetObject(nSockIndex); if (pNetObject && pNetObject->GetConnectKeyState() > 0 && pNetObject->GetGameID() == xData.game_id() && pNetObject->GetAccount() == xData.account() && !xData.name().empty() && !xData.account().empty()) { NFMsg::MsgBase xMsg; if (!xData.SerializeToString(xMsg.mutable_msg_data())) { return; } //playerid在进入游戏之前都是FD,其他时候是真实的ID xMsg.mutable_player_id()->CopyFrom(NFINetModule::NFToPB(pNetObject->GetClientID())); std::string strMsg; if (!xMsg.SerializeToString(&strMsg)) { return; } m_pProxyServerToGameModule->GetClusterModule()->SendByServerID(pNetObject->GetGameID(), NFMsg::EGameMsgID::EGMI_REQ_ENTER_GAME, strMsg); } } }
void NFCProxyServerNet_ServerModule::OnReqServerListProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ReqServerList xMsg; if (!m_pNetModule->ReceivePB(nSockIndex, nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } if (xMsg.type() != NFMsg::RSLT_GAMES_ERVER) { return; } NetObject* pNetObject = m_pNetModule->GetNet()->GetNetObject(nSockIndex); if (pNetObject && pNetObject->GetConnectKeyState() > 0) { //ack all gameserver data NFMsg::AckServerList xData; xData.set_type(NFMsg::RSLT_GAMES_ERVER); NFMapEx<int, ConnectData>& xServerList = m_pProxyServerToGameModule->GetClusterModule()->GetServerList(); ConnectData* pGameData = xServerList.FirstNude(); while (NULL != pGameData) { if (ConnectDataState::NORMAL == pGameData->eState) { NFMsg::ServerInfo* pServerInfo = xData.add_info(); pServerInfo->set_name(pGameData->strName); pServerInfo->set_status(NFMsg::EServerState::EST_NARMAL); pServerInfo->set_server_id(pGameData->nGameID); pServerInfo->set_wait_count(0); } pGameData = xServerList.NextNude(); } m_pNetModule->SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_WORLD_LIST, xData, nSockIndex); } }
int NFCLoginNet_ServerModule::OnLoginProcess( const NFIPacket& msg ) { NFIDENTID nPlayerID; NFMsg::ReqAccountLogin xMsg; if (!RecivePB(msg, xMsg, nPlayerID)) { return 0; } NetObject* pNetObject = GetNet()->GetNetObject(msg.GetFd()); if (pNetObject) { //还没有登录过 if (pNetObject->GetConnectKeyState() == 0) { NFCDataList val; val << pNetObject->GetClientID()<< xMsg.account() << xMsg.password(); m_pEventProcessModule->DoEvent(NFIDENTID(), NFED_ON_CLIENT_LOGIN, val); } } return 0; }
void NFCProxyServerNet_ServerModule::OnReqDelRoleProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { //在没有正式进入游戏之前,nPlayerID都是FD NFGUID nPlayerID; NFMsg::ReqDeleteRole xData; if (!m_pNetModule->ReceivePB(nSockIndex, nMsgID, msg, nLen, xData, nPlayerID)) { return; } NF_SHARE_PTR<ConnectData> pServerData = m_pProxyServerToGameModule->GetClusterModule()->GetServerNetInfo(xData.game_id()); if (pServerData && ConnectDataState::NORMAL == pServerData->eState) { //数据匹配 NetObject* pNetObject = m_pNetModule->GetNet()->GetNetObject(nSockIndex); if (pNetObject && pNetObject->GetConnectKeyState() > 0 && pNetObject->GetGameID() == xData.game_id() && pNetObject->GetAccount() == xData.account()) { m_pProxyServerToGameModule->GetClusterModule()->SendByServerID(pNetObject->GetGameID(), nMsgID, std::string(msg, nLen)); } } }