本文整理汇总了C++中WriteBuffer::AppendBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ WriteBuffer::AppendBuffer方法的具体用法?C++ WriteBuffer::AppendBuffer怎么用?C++ WriteBuffer::AppendBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WriteBuffer
的用法示例。
在下文中一共展示了WriteBuffer::AppendBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AppendCommunityData
void AuthContext::AppendCommunityData(WriteBuffer &theBuf)
{
AutoCrit aCrit(mDataCrit);
theBuf.AppendByte(0); // 0 community ids
theBuf.AppendByte(mCommunityMap.size()); // num community names
AuthLoginCommunityMap::iterator anItr = mCommunityMap.begin();
while(anItr!=mCommunityMap.end())
{
theBuf.AppendWString(anItr->first); // community name
++anItr;
}
int aNumCommnityElementsPos = theBuf.length();
theBuf.SkipBytes(2);
int aNumCommunityElements = 0;
anItr = mCommunityMap.begin();
while(anItr!=mCommunityMap.end()) // Append CD Keys
{
AuthLoginCommunityData &aData = anItr->second;
if(aData.mCDKey.IsValid())
{
ByteBufferPtr aKey = anItr->second.mCDKey.GetRaw();
if(aKey.get()!=NULL)
{
theBuf.AppendByte(1); // Type = CD Key
theBuf.AppendShort(anItr->first.length()*2 + aKey->length() + 2); // length of community + data
theBuf.AppendWString(anItr->first);
theBuf.AppendBytes(aKey->data(),aKey->length());
aNumCommunityElements++;
}
}
++anItr;
}
CDKeyCommunityJoinMap::iterator aKeyJoinItr = mCDKeyCommunityJoinMap.begin(); // Append Community Join By CDKey Info
while(aKeyJoinItr!=mCDKeyCommunityJoinMap.end())
{
ByteBufferPtr aKey = aKeyJoinItr->second.GetRaw();
if(aKey.get()!=NULL)
{
theBuf.AppendByte(7); // Type = Join Community with CD Key
theBuf.AppendShort(aKeyJoinItr->first.length()*2+2 + 4 + aKey->length()); // community name + commnityseq + key
theBuf.AppendWString(aKeyJoinItr->first);
theBuf.AppendLong(0);
theBuf.AppendBytes(aKey->data(),aKey->length());
aNumCommunityElements++;
}
++aKeyJoinItr;
}
SetCommunityUserDataMap::iterator aUserDataItr = mSetCommunityUserDataMap.begin(); // Append User Data for communities
while(aUserDataItr!=mSetCommunityUserDataMap.end())
{
const ByteBuffer *aData = aUserDataItr->second;
if(aData!=NULL)
{
theBuf.AppendByte(8); // Type = SetCommunityUserData
theBuf.AppendShort(aUserDataItr->first.length()*2+2 + 4 + aData->length()); // community name + commnityseq + key
theBuf.AppendWString(aUserDataItr->first);
theBuf.AppendLong(0);
theBuf.AppendBuffer(aData);
aNumCommunityElements++;
}
++aUserDataItr;
}
if(mSecretList.size()>0) // CD Keys -> append login secret
{
theBuf.AppendByte(6); // Type = LoginSecret
unsigned long aPos = theBuf.length();
theBuf.SkipBytes(2);
AppendLoginSecrets(theBuf);
theBuf.SetShort(aPos,theBuf.length()-aPos-2);
aNumCommunityElements++;
}
NicknameMap::iterator aNickItr = mNicknameMap.begin();
while(aNickItr!=mNicknameMap.end())
{
const wstring& aKey = aNickItr->first;
const wstring& aVal = aNickItr->second;
theBuf.AppendByte(4); // retrieve nickname
unsigned long aPos = theBuf.length();
theBuf.SkipBytes(2);
theBuf.AppendWString(aKey);
theBuf.SetShort(aPos,theBuf.length()-aPos-2);
aNumCommunityElements++;
if(!aVal.empty())
{
theBuf.AppendByte(3); // set nickname
unsigned long aPos = theBuf.length();
theBuf.SkipBytes(2);
theBuf.AppendWString(aKey);
theBuf.AppendWString(aVal);
//.........这里部分代码省略.........