本文整理汇总了C++中AttributeValue::SetS方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeValue::SetS方法的具体用法?C++ AttributeValue::SetS怎么用?C++ AttributeValue::SetS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeValue
的用法示例。
在下文中一共展示了AttributeValue::SetS方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlayerLogin
bool MatchMaker::PlayerLogin(std::shared_ptr<PlayerSession> psess, const std::string& playerName, const std::string& playerPass)
{
if (playerName.size() < 3 || playerPass.size() < 3)
return false;
/// password hashing first
std::size_t passwd_hash = std::hash<std::string>{}(playerPass);
GetItemRequest getItemRequest;
getItemRequest.SetTableName(mPlayerTableName);
Aws::StringStream ss;
ss << playerName;
AttributeValue hashKey;
hashKey.SetS(ss.str());
getItemRequest.AddKey("PlayerName", hashKey);
ss.str("");
auto result = mDDBClient->GetItem(getItemRequest);
if (!result.IsSuccess())
{
GConsoleLog->PrintOut(true, "GetItemRequest error: %s\n", result.GetError().GetMessageA().c_str());
return false;
}
auto resultVal = result.GetResult().GetItem();
/// in case of first login, create a new player
if (0 == resultVal.size())
{
/// put request
PutItemRequest putItemRequest;
putItemRequest.SetTableName("GomokuPlayerInfo");
AttributeValue hashKeyAttribute;
ss << playerName;
hashKeyAttribute.SetS(ss.str());
putItemRequest.AddItem("PlayerName", hashKeyAttribute);
ss.str("");
AttributeValue passwdValue;
ss << passwd_hash;
passwdValue.SetS(ss.str());
putItemRequest.AddItem("Password", passwdValue);
ss.str("");
AttributeValue scoreValue;
scoreValue.SetN("1000");
putItemRequest.AddItem("Score", scoreValue);
AttributeValue winValue;
winValue.SetN("0");
putItemRequest.AddItem("Win", winValue);
AttributeValue loseValue;
loseValue.SetN("0");
putItemRequest.AddItem("Lose", loseValue);
auto putResult = mDDBClient->PutItem(putItemRequest);
if (!putResult.IsSuccess())
{
GConsoleLog->PrintOut(true, "PutItemRequest error: %s\n", putResult.GetError().GetMessageA().c_str());
return false;
}
psess->SetPlayerInfo(playerName, 1000);
}
else
{
ss << passwd_hash;
if (resultVal["Password"].GetS() != ss.str())
{
GConsoleLog->PrintOut(true, "Password Mismatch: %s\n", playerName.c_str());
return false;
}
int score = stoi(resultVal["Score"].GetN());
psess->SetPlayerInfo(playerName, score);
}
return true;
}