summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-03-22 19:46:08 +0100
committerMattes D <github@xoft.cz>2015-03-22 19:46:08 +0100
commitc6268483934eb2bfdcb76ae621a0be40f76209f5 (patch)
tree9cf896200c8eaf94ca0f6c90bee3bf9c37dbce5b /src/Protocol/Protocol.h
parentProtoProxy: Fixed connection and logging. (diff)
downloadcuberite-c6268483934eb2bfdcb76ae621a0be40f76209f5.tar
cuberite-c6268483934eb2bfdcb76ae621a0be40f76209f5.tar.gz
cuberite-c6268483934eb2bfdcb76ae621a0be40f76209f5.tar.bz2
cuberite-c6268483934eb2bfdcb76ae621a0be40f76209f5.tar.lz
cuberite-c6268483934eb2bfdcb76ae621a0be40f76209f5.tar.xz
cuberite-c6268483934eb2bfdcb76ae621a0be40f76209f5.tar.zst
cuberite-c6268483934eb2bfdcb76ae621a0be40f76209f5.zip
Diffstat (limited to 'src/Protocol/Protocol.h')
-rw-r--r--src/Protocol/Protocol.h26
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;
} ;