summaryrefslogtreecommitdiffstats
path: root/src/Protocol/LengthenedProtocol.h
blob: 88550989d4ffed399199677a23ad5fc49b726932 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

#pragma once
#include "Protocol.h"

class cLengthenedProtocol : public cProtocol
{
public:
	cLengthenedProtocol(AString a_LogID) :
		cProtocol(a_LogID),
		m_ReceivedData(32 KiB)
	{
	}

protected:
	virtual cProtocolError DataReceived(const char * a_Data, size_t a_Size, std::vector<std::unique_ptr<cClientAction>> & a_Actions) override WARN_UNUSED;
	/** This method should append the actions from incoming packets to a_Action */
	virtual cProtocolError OnDataAddedToBuffer(cByteBuffer & a_Buffer, std::vector<std::unique_ptr<cClientAction>> & a_Action) WARN_UNUSED = 0;

private:

	/** Buffer for the received data */
	cByteBuffer m_ReceivedData;

	/** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets, appends to a_Actions */
	cProtocolError AddReceivedData(const char * a_Data, size_t a_Size, std::vector<std::unique_ptr<cClientAction>> & a_Actions) WARN_UNUSED;
};