本文整理汇总了C++中MessageBuffer::GetReadPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageBuffer::GetReadPointer方法的具体用法?C++ MessageBuffer::GetReadPointer怎么用?C++ MessageBuffer::GetReadPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageBuffer
的用法示例。
在下文中一共展示了MessageBuffer::GetReadPointer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PartialProcessPacket
inline bool PartialProcessPacket(Battlenet::Session* session, MessageBuffer& inputBuffer)
{
MessageBuffer& buffer = session->*outputBuffer;
// We have full read header, now check the data payload
if (buffer.GetRemainingSpace() > 0)
{
// need more data in the payload
std::size_t readDataSize = std::min(inputBuffer.GetActiveSize(), buffer.GetRemainingSpace());
buffer.Write(inputBuffer.GetReadPointer(), readDataSize);
inputBuffer.ReadCompleted(readDataSize);
}
if (buffer.GetRemainingSpace() > 0)
{
// Couldn't receive the whole data this time.
ASSERT(inputBuffer.GetActiveSize() == 0);
return false;
}
// just received fresh new payload
if (!(session->*processMethod)())
{
session->CloseSocket();
return false;
}
return true;
}
示例2: GetClientInfo
void Battlenet::Session::AsyncWrite(ServerPacket* packet)
{
if (!IsOpen())
{
delete packet;
return;
}
TC_LOG_DEBUG("session.packets", "%s Sending %s", GetClientInfo().c_str(), PacketToStringHelper(packet).c_str());
packet->Write();
MessageBuffer buffer;
buffer.Write(packet->GetData(), packet->GetSize());
delete packet;
std::unique_lock<std::mutex> guard(_writeLock);
_crypt.EncryptSend(buffer.GetReadPointer(), buffer.GetActiveSize());
QueuePacket(std::move(buffer), guard);
}