本文整理汇总了C++中MessageBuffer::WriteCompleted方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageBuffer::WriteCompleted方法的具体用法?C++ MessageBuffer::WriteCompleted怎么用?C++ MessageBuffer::WriteCompleted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageBuffer
的用法示例。
在下文中一共展示了MessageBuffer::WriteCompleted方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WritePacketToBuffer
void WorldSocket::WritePacketToBuffer(WorldPacket const& packet, MessageBuffer& buffer)
{
ServerPktHeader header;
uint32 sizeOfHeader = SizeOfServerHeader[_authCrypt.IsInitialized()];
uint32 opcode = packet.GetOpcode();
uint32 packetSize = packet.size();
// Reserve space for buffer
uint8* headerPos = buffer.GetWritePointer();
buffer.WriteCompleted(sizeOfHeader);
if (packetSize > 0x400)
{
CompressedWorldPacket cmp;
cmp.UncompressedSize = packetSize + 4;
cmp.UncompressedAdler = adler32(adler32(0x9827D8F1, (Bytef*)&opcode, 4), packet.contents(), packetSize);
// Reserve space for compression info - uncompressed size and checksums
uint8* compressionInfo = buffer.GetWritePointer();
buffer.WriteCompleted(sizeof(CompressedWorldPacket));
uint32 compressedSize = CompressPacket(buffer.GetWritePointer(), packet);
cmp.CompressedAdler = adler32(0x9827D8F1, buffer.GetWritePointer(), compressedSize);
memcpy(compressionInfo, &cmp, sizeof(CompressedWorldPacket));
buffer.WriteCompleted(compressedSize);
packetSize = compressedSize + sizeof(CompressedWorldPacket);
opcode = SMSG_COMPRESSED_PACKET;
}
else if (!packet.empty())
buffer.Write(packet.contents(), packet.size());
if (_authCrypt.IsInitialized())
{
header.Normal.Size = packetSize;
header.Normal.Command = opcode;
_authCrypt.EncryptSend((uint8*)&header, sizeOfHeader);
}
else
{
header.Setup.Size = packetSize + 4;
header.Setup.Command = opcode;
}
memcpy(headerPos, &header, sizeOfHeader);
}
示例2: EndianConvertReverse
void Battlenet::Session::SendResponse(uint32 token, pb::Message const* response)
{
Header header;
header.set_token(token);
header.set_service_id(0xFE);
header.set_size(response->ByteSize());
uint16 headerSize = header.ByteSize();
EndianConvertReverse(headerSize);
MessageBuffer packet;
packet.Write(&headerSize, sizeof(headerSize));
uint8* ptr = packet.GetWritePointer();
packet.WriteCompleted(header.ByteSize());
header.SerializeToArray(ptr, header.ByteSize());
ptr = packet.GetWritePointer();
packet.WriteCompleted(response->ByteSize());
response->SerializeToArray(ptr, response->ByteSize());
AsyncWrite(&packet);
}
示例3: WritePacketToBuffer
void Socket::WritePacketToBuffer(Packet const& packet, MessageBuffer& buffer)
{
ServerHeader header;
uint32 sizeOfHeader = SizeOfServerHeader;
uint32 opcode = packet.GetOpcode();
uint32 packetSize = packet.size();
// Reserve space for buffer
uint8* headerPos = buffer.GetWritePointer();
buffer.WriteCompleted(sizeOfHeader);
if (!packet.empty())
buffer.Write(packet.contents(), packet.size());
header.Size = packetSize;
header.Command = opcode;
memcpy(headerPos, &header, sizeOfHeader);
}