当前位置: 首页>>代码示例>>C++>>正文


C++ PacketReader类代码示例

本文整理汇总了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;
}
开发者ID:null-null-cn,项目名称:Cumulus,代码行数:26,代码来源:Handshake.cpp

示例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;
	}
开发者ID:wilkystorm,项目名称:Cumulus,代码行数:7,代码来源:Flow.cpp

示例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);
}
开发者ID:jaejungkim,项目名称:MonaServer,代码行数:7,代码来源:Session.cpp

示例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;
}
开发者ID:agazso,项目名称:Cumulus,代码行数:28,代码来源:Handshake.cpp

示例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;
	}
开发者ID:taililong,项目名称:MonaServer,代码行数:7,代码来源:RTMFPFlow.cpp

示例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 );

    }
开发者ID:sdavtaker,项目名称:metaserver-ng,代码行数:34,代码来源:PacketLogging_integration.cpp

示例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);
}
开发者ID:homelee,项目名称:MonaServer,代码行数:7,代码来源:FlashStream.cpp

示例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);
}
开发者ID:MinoaveDev,项目名称:EccoDev,代码行数:8,代码来源:WorldServerConnectHandler.cpp

示例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);
	}
}
开发者ID:arpu,项目名称:Cumulus,代码行数:8,代码来源:Publication.cpp

示例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;
}
开发者ID:luc1el,项目名称:MonaServer,代码行数:8,代码来源:RTMFP.cpp

示例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;
}
开发者ID:191919,项目名称:Cumulus,代码行数:8,代码来源:RTMFP.cpp

示例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));
}
开发者ID:agazso,项目名称:Cumulus,代码行数:9,代码来源:RTMFP.cpp

示例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);
	}
}
开发者ID:arpu,项目名称:Cumulus,代码行数:9,代码来源:Publication.cpp

示例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);
}
开发者ID:JakeShirley,项目名称:Vana,代码行数:10,代码来源:Maps.cpp

示例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);
}
开发者ID:JakeShirley,项目名称:Vana,代码行数:12,代码来源:PlayerDataProvider.cpp


注:本文中的PacketReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。