diff options
Diffstat (limited to 'src/Protocol/Protocol.h')
-rw-r--r-- | src/Protocol/Protocol.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 652b5aa7e..d8399049e 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -14,6 +14,7 @@ #include "../Endianness.h" #include "../Scoreboard.h" #include "../Map.h" +#include "../ByteBuffer.h" @@ -32,6 +33,7 @@ class cChunkDataSerializer; class cFallingBlock; class cCompositeChat; class cStatManager; +class cPacketizer; @@ -47,7 +49,9 @@ class cProtocol { public: cProtocol(cClientHandle * a_Client) : - m_Client(a_Client) + m_Client(a_Client), + m_OutPacketBuffer(64 KiB), + m_OutPacketLenBuffer(20) // 20 bytes is more than enough for one VarInt { } @@ -136,11 +140,27 @@ public: virtual AString GetAuthServerID(void) = 0; protected: + friend class cPacketizer; + cClientHandle * m_Client; - cCriticalSection m_CSPacket; // Each SendXYZ() function must acquire this CS in order to send the whole packet at once - /// A generic data-sending routine, all outgoing packet data needs to be routed through this so that descendants may override it + /** Provides synchronization for sending the entire packet at once. + Each SendXYZ() function must acquire this CS in order to send the whole packet at once. + Automated via cPacketizer class. */ + cCriticalSection m_CSPacket; + + /** Buffer for composing the outgoing packets, through cPacketizer */ + cByteBuffer m_OutPacketBuffer; + + /** Buffer for composing packet length (so that each cPacketizer instance doesn't allocate a new cPacketBuffer) */ + cByteBuffer m_OutPacketLenBuffer; + + /** A generic data-sending routine, all outgoing packet data needs to be routed through this so that descendants may override it. */ virtual void SendData(const char * a_Data, size_t a_Size) = 0; + + /** Sends a single packet contained within the cPacketizer class. + The cPacketizer's destructor calls this to send the contained packet; protocol may transform the data (compression in 1.8 etc). */ + virtual void SendPacket(cPacketizer & a_Packet) = 0; } ; |