2013-11-21 13:42:38 +01:00
|
|
|
#ifndef NETWORK_DEPENDENCIES_MESSAGE_HEADER_H
|
|
|
|
#define NETWORK_DEPENDENCIES_MESSAGE_HEADER_H
|
|
|
|
|
2013-11-25 19:00:33 +01:00
|
|
|
/////////////////////////////////////
|
|
|
|
// Created by Pontus Fransson 2013 //
|
|
|
|
/////////////////////////////////////
|
2013-11-21 13:42:38 +01:00
|
|
|
|
|
|
|
#include <string>
|
2013-11-21 14:49:30 +01:00
|
|
|
#include "../Protocols.h"
|
2013-11-27 11:01:22 +01:00
|
|
|
#include "../OysterByte.h"
|
2013-11-21 13:42:38 +01:00
|
|
|
|
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Network
|
|
|
|
{
|
|
|
|
namespace Messages
|
|
|
|
{
|
|
|
|
class MessageHeader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MessageHeader();
|
|
|
|
virtual ~MessageHeader();
|
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
virtual void Pack(Protocols::ProtocolHeader& header, OysterByte& bytes );
|
|
|
|
virtual void Unpack(OysterByte& bytes, Protocols::ProtocolHeader& header);
|
2013-11-21 13:42:38 +01:00
|
|
|
|
|
|
|
protected:
|
2013-11-25 19:00:33 +01:00
|
|
|
//Pack variables to messages
|
2013-11-27 11:01:22 +01:00
|
|
|
void PackBool(bool i, OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
void PackChar(char i, OysterByte& bytes);
|
|
|
|
void PackUnsignedChar(unsigned char i, OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
void PackShort(short i, OysterByte& bytes);
|
|
|
|
void PackUnsignedShort(unsigned short i, OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
void PackInt(int i, OysterByte& bytes);
|
|
|
|
void PackUnsignedInt(unsigned int i, OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
void PackInt64(__int64 i, OysterByte& bytes);
|
|
|
|
void PackUnsignedInt64(unsigned __int64 i, OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
void PackFloat(float i, OysterByte& bytes);
|
|
|
|
void PackFloat(float i[], unsigned int elementCount, OysterByte& bytes);
|
|
|
|
void PackDouble(double i, OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
void PackStr(char str[], OysterByte& bytes);
|
|
|
|
void PackStr(std::string str, OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-12-03 11:46:46 +01:00
|
|
|
//Maybe
|
2013-11-25 19:00:33 +01:00
|
|
|
//TODO: Add Pack functions for Vec2, 3, 4 and maybe Matrix. Etc.
|
2013-12-03 11:46:46 +01:00
|
|
|
|
2013-11-25 19:00:33 +01:00
|
|
|
|
|
|
|
//Unpack variables from message
|
2013-11-27 11:01:22 +01:00
|
|
|
bool UnpackBool(OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
char UnpackChar(OysterByte& bytes);
|
|
|
|
unsigned char UnpackUnsignedChar(OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
short UnpackShort(OysterByte& bytes);
|
|
|
|
unsigned short UnpackUnsignedShort(OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
int UnpackInt(OysterByte& bytes);
|
|
|
|
unsigned int UnpackUnsignedInt(OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
__int64 UnpackInt64(OysterByte& bytes);
|
|
|
|
unsigned __int64 UnpackUnsignedInt64(OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
float UnpackFloat(OysterByte& bytes);
|
|
|
|
float* UnpackFloat(unsigned int& elementCount, OysterByte& bytes);
|
|
|
|
double UnpackDouble(OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
std::string UnpackStr(OysterByte& bytes);
|
2013-11-25 19:00:33 +01:00
|
|
|
|
2013-12-03 11:46:46 +01:00
|
|
|
//Maybe
|
2013-11-25 19:00:33 +01:00
|
|
|
//TODO: Add Unpack functions for Vec2, 3, 4 and maybe Matrix. Etc.
|
2013-11-21 13:42:38 +01:00
|
|
|
|
|
|
|
|
2013-11-27 11:01:22 +01:00
|
|
|
//Sets the this->size to the first position in msg
|
|
|
|
void SetSize(OysterByte& bytes);
|
2013-11-22 15:48:49 +01:00
|
|
|
|
2013-11-21 13:42:38 +01:00
|
|
|
private:
|
2013-11-27 11:01:22 +01:00
|
|
|
unsigned int size;
|
2013-11-21 13:42:38 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|