Switching from ASN.1 (asn1c) to google protocol buffers. Some things are still missing (packet verification, tests, ...), this is very early stuff.

This commit is contained in:
lotodore
2012-09-18 15:57:58 +02:00
parent 9c33f6e08a
commit 86c58fc7c8
16 changed files with 52009 additions and 1828 deletions
+5 -4
View File
@@ -83,9 +83,10 @@ SenderHelper::SetCloseAfterSend(boost::shared_ptr<SessionData> session)
void
SenderHelper::InternalStorePacket(SendBuffer &tmpBuffer, boost::shared_ptr<NetPacket> packet)
{
asn_enc_rval_t e = der_encode(&asn_DEF_PokerTHMessage, packet->GetMsg(), &SendBuffer::EncodeToBuf, &tmpBuffer);
//cerr << "OUT:" << endl << packet->ToString() << endl;
if (e.encoded == -1)
LOG_ERROR("Failed to encode NetPacket: " << packet->GetMsg()->present);
uint32_t packetSize = packet->GetMsg()->ByteSize();
char *buf = new char[packetSize + NET_HEADER_SIZE];
*((uint32_t *)buf) = htonl(packetSize);
packet->GetMsg()->SerializeToArray(&buf[NET_HEADER_SIZE], packetSize);
SendBuffer::EncodeToBuf(buf, packetSize + NET_HEADER_SIZE, &tmpBuffer);
}