本文整理汇总了C++中PacketReader类的典型用法代码示例。如果您正苦于以下问题:C++ PacketReader类的具体用法?C++ PacketReader怎么用?C++ PacketReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PacketReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: add
void add(PacketReader& fragment) {
string::size_type old = _buffer.size();
_buffer.resize(old + (string::size_type)fragment.available());
if(_buffer.size()>old)
memcpy(&_buffer[old],fragment.current(),(size_t)fragment.available());
++(UInt16&)fragments;
}
示例3: receiveWithoutFlush
void Session::receiveWithoutFlush(PacketReader& packet) {
if(died)
return;
if (!dumpJustInDebug || (dumpJustInDebug && Logs::GetLevel()>=7))
DUMP(packet.data(),packet.size(),"Request from ",peer.address.toString())
packetHandler(packet);
}
示例4: 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;
}
示例5: add
void add(PacketReader& fragment) {
string::size_type old = _pBuffer->size();
_pBuffer->resize(old + fragment.available(),true);
if(_pBuffer->size()>old)
memcpy(_pBuffer->data()+old,fragment.current(),fragment.available());
++(UInt16&)fragments;
}
示例6: test_PacketReader_parseBinaryFile_append
void test_PacketReader_parseBinaryFile_append()
{
/*
* Add our 2 packets
*/
pl->LogPacket(*mp1);
pl->LogPacket(*mp2);
pl->flush(0);
/*
* First parse, should have 2
*/
unsigned int i = p->parseBinaryFile(pl->getFile());
CPPUNIT_ASSERT( i == 2 );
/*
* Trigger append mode
*/
p->setAppend(true);
/*
* Second parse. Since no reset, should have 4
*/
i = p->parseBinaryFile(pl->getFile());
CPPUNIT_ASSERT( i = 4 );
/*
* And back again
*/
p->setAppend(false);
i = p->parseBinaryFile(pl->getFile());
CPPUNIT_ASSERT( i == 2 );
}
示例7: rawHandler
void FlashStream::rawHandler(UInt8 type, PacketReader& packet, FlashWriter& writer) {
if(packet.read16()==0x22) { // TODO Here we receive RTMFP flow sync signal, useless to support it!
//TRACE("Sync ",id," : ",data.read32(),"/",data.read32());
return;
}
ERROR("Raw message ",Format<UInt8>("%.2x",type),"/",packet.read16()," unknown on stream ",id);
}
示例8: whisperPlayer
void WorldServerConnectHandler::whisperPlayer(PacketReader &packet) {
int32_t whisperee = packet.get<int32_t>();
string whisperer = packet.getString();
uint16_t channel = packet.get<int16_t>();
string message = packet.getString();
PlayersPacket::whisperPlayer(PlayerDataProvider::Instance()->getPlayer(whisperee), whisperer, channel, message);
}
示例9: pushRawPacket
void Publication::pushRawPacket(UInt8 type,PacketReader& packet) {
list<Listener*>::const_iterator it;
int pos = packet.position();
for(it=_listeners.begin();it!=_listeners.end();++it) {
(*it)->pushRawPacket(type,packet);
packet.reset(pos);
}
}
示例10: Decode
bool RTMFP::Decode(Exception& ex,RTMFPEngine& aesDecrypt,PacketReader& packet) {
// Decrypt
aesDecrypt.process(packet.current(),(UInt8*)packet.current(),packet.available());
bool result = ReadCRC(packet);
if (!result)
ex.set(Exception::CRYPTO, "Bad RTMFP CRC sum computing");
return result;
}
示例11: Unpack
UInt32 RTMFP::Unpack(PacketReader& packet) {
packet.reset();
UInt32 id=0;
for(int i=0;i<3;++i)
id ^= packet.read32();
packet.reset(4);
return id;
}
示例12: Decode
bool RTMFP::Decode(AESEngine& aesDecrypt,PacketReader& packet) {
// Decrypt
aesDecrypt.process(packet.current(),packet.current(),packet.available());
// Check the first 2 CRC bytes
packet.reset(4);
UInt16 sum = packet.read16();
return (sum == CheckSum(packet));
}
示例13: pushVideoPacket
void Publication::pushVideoPacket(PacketReader& packet) {
UInt32 time = packet.read32(); // TODO?
list<Listener*>::const_iterator it;
int pos = packet.position();
for(it=_listeners.begin();it!=_listeners.end();++it) {
(*it)->pushVideoPacket(packet);
packet.reset(pos);
}
}
示例14: useScriptedPortal
void Maps::useScriptedPortal(Player *player, PacketReader &packet) {
packet.skipBytes(1);
string portalname = packet.getString();
PortalInfo *portal = getMap(player->getMap())->getPortal(portalname);
if (portal == nullptr) // Exit the function if portal is not found
return;
usePortal(player, portal);
}
示例15: memcpy
// Stored packets
void PlayerDataProvider::parseIncomingPacket(PacketReader &packet) {
int32_t playerid = packet.get<int32_t>();
bool fromCashOrMts = packet.getBool();
size_t psize = packet.getBufferLength();
unsigned char *buf = new unsigned char[psize]; // Prevent the packet memory from being freed by external sources
memcpy(buf, packet.getBuffer(), psize);
m_packets[playerid].reset(new PacketReader(buf, psize));
SyncPacket::playerBuffsTransferred(ChannelServer::Instance()->getWorldConnection(), playerid, fromCashOrMts);
}