コード例 #1
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
}
コード例 #2
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);
}