本文整理汇总了C++中PacketReader::shrink方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketReader::shrink方法的具体用法?C++ PacketReader::shrink怎么用?C++ PacketReader::shrink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader::shrink方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: packetHandler
void Handshake::packetHandler(PacketReader& packet) {
UInt8 marker = packet.read8();
if(marker!=0x0b) {
ERROR("Marker handshake wronk : must be '0B' and not '%02x'",marker);
return;
}
UInt16 time = packet.read16();
UInt8 id = packet.read8();
packet.shrink(packet.read16()); // length
PacketWriter& packetOut = writer();
UInt8 idResponse=0;
{
PacketWriter response(packetOut,3);
idResponse = handshakeHandler(id,packet,response);
if(idResponse==0)
return;
}
packetOut << (UInt8)idResponse;
packetOut << (UInt16)(packetOut.length()-packetOut.position()-2);
send(true);
// reset farid to 0!
_farId=0;
}
示例2: packetHandler
void Handshake::packetHandler(PacketReader& packet) {
UInt8 marker = packet.read8();
if(marker!=0x0b) {
ERROR("Marker handshake wrong : should be 0b and not %u",marker);
return;
}
UInt16 time = packet.read16();
UInt8 id = packet.read8();
packet.shrink(packet.read16()); // length
PacketWriter& response(writer());
UInt32 pos = response.position();
response.next(3);
UInt8 idResponse = handshakeHandler(id,packet,response);
response.reset(pos);
if(idResponse>0) {
response.write8(idResponse);
response.write16(response.length()-response.position()-2);
flush();
}
// reset farid to 0!
(UInt32&)farId=0;
}
示例3: buildPacket
bool WSSession::buildPacket(PacketReader& packet) {
if (packet.available()<2)
return false;
UInt8 type = packet.read8() & 0x0F;
UInt8 lengthByte = packet.read8();
UInt32 size=lengthByte&0x7f;
if (size==127) {
if (packet.available()<8)
return false;
size = (UInt32)packet.read64();
} else if (size==126) {
if (packet.available()<2)
return false;
size = packet.read16();
}
if(lengthByte&0x80)
size += 4;
if (packet.available()<size)
return false;
packet.shrink(size);
if (lengthByte & 0x80) {
shared_ptr<WSUnmasking> pWSUnmasking(new WSUnmasking(invoker, packet.current(),packet.available(), type));
decode<WSUnmasking>(pWSUnmasking);
} else {
packet.reset(packet.position()-1);
*(UInt8*)packet.current() = type;
}
return true;
}
示例4: packetHandler
void RTMFPHandshake::packetHandler(PacketReader& packet) {
UInt8 marker = packet.read8();
if(marker!=0x0b) {
ERROR("Marker handshake wrong : should be 0b and not ",Format<UInt8>("%.2x",marker));
return;
}
UInt16 time = packet.read16();
UInt8 id = packet.read8();
packet.shrink(packet.read16()); // length
PacketWriter& response(this->packet());
UInt32 oldSize(response.size());
response.next(3); // type and size
UInt8 idResponse = handshakeHandler(id,packet,response);
if(idResponse>0)
BinaryWriter(response,oldSize).write8(idResponse).write16(response.size()-oldSize-3);
else
response.clear(oldSize);
}