示例#1
0
void ChangeRecordSessionPacket::serialize( Archive& ar )
{
	SessionPacket::serialize( ar );
	ar << (int&)m_cType;
	ar << COMPACT_INT(m_iPos);	
	ar << COMPACT_INT(m_iLength);
	ar << COMPACT_INT(m_iAdjust);
	ar << COMPACT_INT(m_iRev);
	ar << COMPACT_INT(m_iRemoteRev);
}
示例#2
0
void GlobSessionPacket::serialize( Archive& ar )
{
	SessionPacket::serialize( ar );
	
	unsigned int count;
	if (ar.isLoading()) 
	{
		// load packet count
		ar << COMPACT_INT(count);
		m_pPackets.resize( count, NULL );
		
		// load packets
		for (size_t i=0; i<m_pPackets.size(); ++i)
		{
			UT_uint8 classId;
			ar << classId;
			SessionPacket* newPacket = static_cast<SessionPacket*>( Packet::createPacket( (PClassType)classId ) );
			UT_ASSERT(newPacket);		// should this be safer?
			newPacket->setParent( this );
			ar << *newPacket;
			m_pPackets[i] = newPacket;
			// for efficiency reasons, childs of a glob don't serialize their session 
			// and document id's; therefor we set them now manually
			newPacket->setSessionId(getSessionId());
			newPacket->setDocUUID(getDocUUID());
		}
	} 
	else 
	{
		// save packet count
		count = m_pPackets.size();
		ar << COMPACT_INT(count);
		
		// save packets
		for (size_t i=0; i<m_pPackets.size(); ++i) 
		{
			// get and check packet
			SessionPacket* sp = m_pPackets[i];
			UT_ASSERT(sp);				// this really may NEVER fail or addPacket malfunctioned!
			UT_uint8 classId = sp->getClassType();
			ar << classId << *sp;
		}
	}
}
Packet* AccountHandler::_createPacket(const std::string& packet, BuddyPtr pBuddy)
{
	UT_return_val_if_fail(pBuddy, NULL);
	
	// create archive
	IStrArchive isa( packet );
	
	// serialize version
	int version;
	isa << COMPACT_INT(version);
	if (version != ABICOLLAB_PROTOCOL_VERSION)
	{
		if (version > 0)
		{
			UT_DEBUGMSG(("Discarding packet, wrong version %d (expected %d)\n", version, ABICOLLAB_PROTOCOL_VERSION));
			_sendProtocolError(pBuddy, PE_Invalid_Version);
			return NULL;
		}
		else
		{
			UT_DEBUGMSG(("Got error packet (hopefully), revision=%d\n", version));
			// if it's a version 0 message, handle normally, picked up in _handlePacket
		}
	}
	
	// serialize class id and attempt to reconstruct
	UT_uint8 classId;
	isa << classId;
	Packet* newPacket = Packet::createPacket( (PClassType)classId );
	if (!newPacket)
	{
		UT_DEBUGMSG(("Discarding packet, got unknown class %d\n", classId));
		return NULL;
	}
		
	// debug
	UT_DEBUGMSG(("PACKET DESERIALIZED: [%s] %u bytes in serialized string\n", Packet::getPacketClassname( (PClassType)classId ), isa.Size()));
	
	// serialize packet
	isa << *newPacket;
	
	return newPacket;
}
void AccountHandler::_createPacketStream( std::string& sString, const Packet* pPacket )
{
	UT_return_if_fail( pPacket );
	
	// create archive
	OStrArchive osa;
	
	// serialize version
	int version = pPacket->getProtocolVersion();
	osa << COMPACT_INT(version);
	
	// serialize class id
	UT_uint8 classId = pPacket->getClassType();
	osa << classId;
	
	// serialize packet
	osa << const_cast<Packet&>( *pPacket );		// it's a writing archive, so cast is safe
	
	sString = osa.getData();
	
	// debug
	UT_DEBUGMSG(("PACKET SENT: [%s] %u bytes in serialized string\n", Packet::getPacketClassname( (PClassType)classId ), osa.Size()));
}
void ProtocolErrorPacket::serialize(Archive & ar)
{
	Packet::serialize( ar );
	ar << COMPACT_INT(m_errorEnum) << COMPACT_INT(m_remoteVersion);
}
示例#6
0
void RevertAckSessionPacket::serialize( Archive& ar )
{
	SessionPacket::serialize( ar );
	ar << COMPACT_INT(m_iRev);
}
示例#7
0
void SignalSessionPacket::serialize( Archive& ar )
{
	SessionPacket::serialize( ar );
	ar << COMPACT_INT(m_iSignal);
}