2011-05-21 21:02:37 +02:00
|
|
|
#ifndef INPUTMESSAGE_H
|
|
|
|
#define INPUTMESSAGE_H
|
|
|
|
|
2011-07-28 01:01:33 +02:00
|
|
|
#include "netdeclarations.h"
|
2011-05-21 21:02:37 +02:00
|
|
|
|
|
|
|
class InputMessage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum {
|
2011-05-31 07:24:30 +02:00
|
|
|
BUFFER_MAXSIZE = 4096,
|
2011-05-30 05:11:12 +02:00
|
|
|
HEADER_POS = 0,
|
2011-05-21 21:02:37 +02:00
|
|
|
HEADER_LENGTH = 2,
|
2011-05-30 05:11:12 +02:00
|
|
|
CHECKSUM_POS = 2,
|
|
|
|
CHECKSUM_LENGTH = 4,
|
|
|
|
DATA_POS = 6,
|
|
|
|
UNENCRYPTED_DATA_POS = 8
|
2011-05-21 21:02:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
InputMessage();
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
|
2011-08-01 06:28:41 +02:00
|
|
|
uint8 getU8(bool blockReadPos = false);
|
|
|
|
uint16 getU16(bool blockReadPos = false);
|
|
|
|
uint32 getU32(bool blockReadPos = false);
|
|
|
|
uint64 getU64(bool blockReadPos = false);
|
2011-05-21 21:02:37 +02:00
|
|
|
std::string getString();
|
|
|
|
|
2011-08-01 06:28:41 +02:00
|
|
|
void skipBytes(uint16 bytes) { m_readPos += bytes; }
|
2011-07-28 01:01:33 +02:00
|
|
|
uint8* getBuffer() { return m_buffer; }
|
2011-05-30 05:11:12 +02:00
|
|
|
uint16 getMessageSize() { return m_messageSize; }
|
|
|
|
void setMessageSize(uint16 messageSize) { m_messageSize = messageSize; }
|
|
|
|
bool end() { return m_readPos == m_messageSize; }
|
2011-05-21 21:02:37 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool canRead(int bytes);
|
|
|
|
|
2011-05-30 05:11:12 +02:00
|
|
|
uint16 m_readPos;
|
|
|
|
uint16 m_messageSize;
|
|
|
|
uint8 m_buffer[BUFFER_MAXSIZE];
|
2011-05-21 21:02:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|