Ejemplo n.º 1
0
bool NFCPVPMatchRedisModule::GetPlayerRoomIDList(const std::vector<NFGUID>& xPlayerList, std::vector<NFGUID>& vecRoomIDList)
{
	NF_SHARE_PTR<NFINoSqlDriver> pNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent();
    if (pNoSqlDriver)
    {
        std::vector<std::string> vFields;
        std::vector<std::string> vValues;
        std::string strKey = MakePlayerRoomKey();
        std::string strData;

        for (int i = 0; i < xPlayerList.size(); ++i)
        {
            vFields.push_back(xPlayerList[i].ToString());
        }

        if (pNoSqlDriver->HMGet(strKey, vFields, vValues))
        {
            for (int i = 0; i < vValues.size(); ++i)
            {
                NFGUID xIdent;
                xIdent.FromString(vValues[i]);
                vecRoomIDList.push_back(xIdent);
            }

            return true;
        }
    }

    return false;
}
Ejemplo n.º 2
0
bool NFCPVPMatchRedisModule::GetRoomInfoList(const std::vector<NFGUID>& xRoomIDList, std::vector<NFMsg::PVPRoomInfo>& vecRoomInfoList)
{
	NF_SHARE_PTR<NFINoSqlDriver> pNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent();
    if (pNoSqlDriver)
    {
        std::string strKey = MakePvpRoomRedisKey();
        std::vector<std::string> vFields;
        std::vector<std::string> vValues;

        for (int i = 0; i < xRoomIDList.size(); ++i)
        {
            vFields.push_back(xRoomIDList[i].ToString());
        }

		if (vFields.size()>0)
		{
			std::string strData;
			if (pNoSqlDriver->HMGet(strKey, vFields, vValues))
			{
				for (int i = 0; i < vValues.size(); ++i)
				{
					const std::string& strData = vValues[i];
					NFMsg::PVPRoomInfo xBaseInfo;
					if (xBaseInfo.ParseFromString(strData))
					{
						vecRoomInfoList.push_back(xBaseInfo);
					}
				}
				return true;
			}
		}
		else
		{
			return false;
		}
    }

    return false;
}