Skip to content

Commit

Permalink
Merge pull request #61 from ketoo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ketoo authored Sep 21, 2017
2 parents a454545 + a3af573 commit 3ff4af1
Show file tree
Hide file tree
Showing 25 changed files with 203 additions and 1,213 deletions.
52 changes: 49 additions & 3 deletions NFComm/NFCore/NFCProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,58 @@ std::string NFCProperty::ToString()

bool NFCProperty::FromString(const std::string& strData)
{
if (!mxData)
try
{
switch (GetType())
{
case TDATA_INT:
SetInt(lexical_cast<int64_t> (strData));
break;

case TDATA_FLOAT:
SetFloat(lexical_cast<float> (strData));
break;

case TDATA_STRING:
SetString(strData);
break;

case TDATA_OBJECT:
{
NFGUID xID;
xID.FromString(strData);
SetObject(xID);
}
break;

case TDATA_VECTOR2:
{
NFVector2 v;
v.FromString(strData);
SetVector2(v);
}
break;

case TDATA_VECTOR3:
{
NFVector3 v;
v.FromString(strData);
SetVector3(v);
}
break;

default:
break;
}

return true;
}
catch (...)
{
mxData = NF_SHARE_PTR<NFData>(NF_NEW NFData(GetType()));
return false;
}

return mxData->FromString(strData);
return false;
}

bool NFCProperty::DeSerialization()
Expand Down
8 changes: 8 additions & 0 deletions NFComm/NFNetPlugin/NFCNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
#include "event2/event.h"
#include <atomic>

/*
if any one upgurade the networking library(libevent), the evbuffer size must be changed
*MODIFY--libevent/buffer.c
#define EVBUFFER_MAX_READ 4096
TO
#define EVBUFFER_MAX_READ 65536
*/

void NFCNet::conn_writecb(struct bufferevent* bev, void* user_data)
{

Expand Down
23 changes: 15 additions & 8 deletions NFComm/NFNoSqlPlugin/NFCNoSqlDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,14 @@ const bool NFCNoSqlDriver::HMGet(const std::string & strKey, const std::vector<s
try
{
m_pNoSqlClient->hmget(strKey, fieldVec, valueVec);
//if (std::string::npos == strValue.find(mstrNoExistKey))
//{
// return true;
//}
for (int i = 0; i < valueVec.size(); ++i)
{
if (std::string::npos != valueVec[i].find(mstrNoExistKey))
{
valueVec[i] = "";
}
}

return fieldVec.size() == valueVec.size();
}
REDIS_CATCH(__FUNCTION__, __LINE__);
Expand Down Expand Up @@ -404,10 +408,13 @@ const bool NFCNoSqlDriver::HValues(const std::string & strKey, std::vector<std::
try
{
m_pNoSqlClient->hvals(strKey, valueVec);
//if (std::string::npos == strValue.find(mstrNoExistKey))
//{
// return true;
//}
for (int i = 0; i < valueVec.size(); ++i)
{
if (std::string::npos != valueVec[i].find(mstrNoExistKey))
{
valueVec[i] = "";
}
}
return true;
}
REDIS_CATCH(__FUNCTION__, __LINE__);
Expand Down
21 changes: 8 additions & 13 deletions NFComm/NFPluginModule/NFICommonRedisModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,25 @@ class NFICommonRedisModule
virtual std::string GetPropertyCacheKey(const NFGUID& self) = 0;
virtual std::string GetRecordCacheKey(const NFGUID& self) = 0;

virtual std::string GetPropertyStorageKey(const NFGUID& self) = 0;
virtual std::string GetRecordStorageKey(const NFGUID& self) = 0;

virtual std::string GetAccountCacheKey(const std::string& strAccount) = 0;
virtual std::string GetTileCacheKey(const int& nSceneID) = 0;

virtual NF_SHARE_PTR<NFIPropertyManager> GetCachePropertyInfo(const NFGUID& self, const std::string& strClassName) = 0;
virtual NF_SHARE_PTR<NFIRecordManager> GetCacheRecordInfo(const NFGUID& self, const std::string& strClassName) = 0;
virtual NF_SHARE_PTR<NFIPropertyManager> GetCachePropertyInfo(const NFGUID& self, const std::string& strClassName, std::vector<std::string>& vKeyCacheList, std::vector<std::string>& vValueCacheList) = 0;
virtual NF_SHARE_PTR<NFIRecordManager> GetCacheRecordInfo(const NFGUID& self, const std::string& strClassName, std::vector<std::string>& vKeyCacheList, std::vector<std::string>& vValueCacheList) = 0;

virtual NF_SHARE_PTR<NFIPropertyManager> NewPropertyManager(const std::string& strClassName) = 0;
virtual NF_SHARE_PTR<NFIRecordManager> NewRecordManager(const std::string& strClassName) = 0;

virtual bool SaveCachePropertyInfo(const NFGUID& self, NF_SHARE_PTR<NFIPropertyManager> pPropertyManager, const bool bCache) = 0;
virtual bool SaveCacheRecordInfo(const NFGUID& self, NF_SHARE_PTR<NFIRecordManager> pRecordManager, const bool bCache) = 0;
virtual bool SaveCachePropertyInfo(const NFGUID& self, NF_SHARE_PTR<NFIPropertyManager> pPropertyManager) = 0;
virtual bool SaveCacheRecordInfo(const NFGUID& self, NF_SHARE_PTR<NFIRecordManager> pRecordManager) = 0;

//support hset
virtual bool ConvertPBToPropertyManager(std::vector<std::string>& vKeyList, std::vector<std::string>& vValueList, NF_SHARE_PTR<NFIPropertyManager>& pPropertyManager, const bool bCache) = 0;
virtual bool ConvertPBToRecordManager(std::vector<std::string>& vKeyList, std::vector<std::string>& vValueList, NF_SHARE_PTR<NFIRecordManager>& pRecordManager, const bool bCache) = 0;

//support hmset
virtual bool ConvertPBToPropertyManager(std::vector<std::string>& vKeyList, std::vector<std::string>& vValueList, NF_SHARE_PTR<NFIPropertyManager>& pPropertyManager) = 0;
virtual bool ConvertPBToRecordManager(std::vector<std::string>& vKeyList, std::vector<std::string>& vValueList, NF_SHARE_PTR<NFIRecordManager>& pRecordManager) = 0;

//support hmset
virtual bool ConvertPropertyManagerToPB(const NF_SHARE_PTR<NFIPropertyManager>& pPropertyManager, std::vector<std::string>& vKeyList, std::vector<std::string>& vValueList, const bool bCache) = 0;
virtual bool ConvertRecordToPB(const NF_SHARE_PTR<NFIRecordManager>& pRecordManager, std::vector<std::string>& vKeyList, std::vector<std::string>& vValueList, const bool bCache) = 0;
virtual bool ConvertPropertyManagerToPB(const NF_SHARE_PTR<NFIPropertyManager>& pPropertyManager, std::vector<std::string>& vKeyList, std::vector<std::string>& vValueList) = 0;
virtual bool ConvertRecordManagerToPB(const NF_SHARE_PTR<NFIRecordManager>& pRecordManager, std::vector<std::string>& vKeyList, std::vector<std::string>& vValueList) = 0;

};

Expand Down
1 change: 0 additions & 1 deletion NFComm/NFPluginModule/NFIPVPRedisModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class NFIPVPRedisModule
virtual bool DeleteRoomInfo(const NFGUID& xRoomID) = 0;
virtual bool DeleteRoomInfoList(const std::vector<NFGUID>& xRoomIDList) = 0;
virtual bool DeleteStatusRoomID(const int nPVPMode, const int nGrade, const int nStatus, const NFGUID& xRoomID) = 0;
virtual bool DeletetStatusRoomID(const int nPVPMode, const int nGrade, const int nStatus, const std::vector<NFGUID>& xRoomIDList) = 0;

virtual bool PushSinglePlayer(const NFGUID& self, const int nPVPMode, const int nGrade) = 0;
virtual bool PopSinglePlayer(NFGUID& self, const int nPVPMode, const int nGrade) = 0;
Expand Down
29 changes: 0 additions & 29 deletions NFComm/NFPluginModule/NFITeamBroadcastModule.h

This file was deleted.

39 changes: 0 additions & 39 deletions NFComm/NFPluginModule/NFITeamDataModule.h

This file was deleted.

37 changes: 0 additions & 37 deletions NFComm/NFPluginModule/NFITeamModule.h

This file was deleted.

21 changes: 0 additions & 21 deletions NFComm/NFPluginModule/NFITeamPVPModule.h

This file was deleted.

19 changes: 11 additions & 8 deletions NFServer/NFDataAgent_NosqlPlugin/NFCAccountRedisModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool NFCAccountRedisModule::AfterInit()
int NFCAccountRedisModule::VerifyAccount(const std::string& strAccount, const std::string& strPwd)
{
std::string strAccountKey = m_pCommonRedisModule->GetAccountCacheKey(strAccount);
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuitRandom();
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuit(strAccount);
if (xNoSqlDriver)
{
std::string strPassword;
Expand All @@ -52,7 +52,7 @@ int NFCAccountRedisModule::VerifyAccount(const std::string& strAccount, const st
bool NFCAccountRedisModule::AddAccount(const std::string & strAccount, const std::string & strPwd)
{
std::string strAccountKey = m_pCommonRedisModule->GetAccountCacheKey(strAccount);
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuitRandom();
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuit(strAccount);
if (xNoSqlDriver)
{
return xNoSqlDriver->HSet(strAccountKey, "Password", strPwd);
Expand All @@ -63,7 +63,7 @@ bool NFCAccountRedisModule::AddAccount(const std::string & strAccount, const std
bool NFCAccountRedisModule::ExistAccount(const std::string & strAccount)
{
std::string strAccountKey = m_pCommonRedisModule->GetAccountCacheKey(strAccount);
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuitRandom();
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuit(strAccount);
if (xNoSqlDriver)
{
return xNoSqlDriver->Exists(strAccountKey);
Expand All @@ -74,7 +74,7 @@ bool NFCAccountRedisModule::ExistAccount(const std::string & strAccount)

bool NFCAccountRedisModule::ExistRoleName(const std::string & strRoleName)
{
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuitRandom();
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent();
if (xNoSqlDriver)
{
return xNoSqlDriver->Exists(strRoleName);
Expand All @@ -86,16 +86,19 @@ bool NFCAccountRedisModule::ExistRoleName(const std::string & strRoleName)
bool NFCAccountRedisModule::CreateRole(const std::string & strAccount, const std::string & strRoleName, const NFGUID & id)
{
std::string strAccountKey = m_pCommonRedisModule->GetAccountCacheKey(strAccount);
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuitRandom();
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuit(strAccount);
if (xNoSqlDriver)
{
if (xNoSqlDriver->Exists(strAccountKey) && !xNoSqlDriver->Exists(strRoleName))
{
xNoSqlDriver->HSet(strAccountKey, NFrame::Player::Name(), strRoleName);
xNoSqlDriver->HSet(strAccountKey, NFrame::Player::ID(), id.ToString());

xNoSqlDriver->HSet(strRoleName, NFrame::Player::ID(), id.ToString());

NF_SHARE_PTR<NFINoSqlDriver> xRoleNameNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent();
if (xRoleNameNoSqlDriver)
{
xRoleNameNoSqlDriver->HSet(strRoleName, NFrame::Player::ID(), id.ToString());
}
/*
std::vector<std::string> vKey;
std::vector<std::string> vValue;
Expand All @@ -114,7 +117,7 @@ bool NFCAccountRedisModule::CreateRole(const std::string & strAccount, const std
bool NFCAccountRedisModule::GetRoleInfo(const std::string & strAccount, std::string & strRoleName, NFGUID & id)
{
std::string strAccountKey = m_pCommonRedisModule->GetAccountCacheKey(strAccount);
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuitRandom();
NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuit(strAccount);
if (xNoSqlDriver)
{
if (xNoSqlDriver->Exists(strAccountKey))
Expand Down
Loading

0 comments on commit 3ff4af1

Please sign in to comment.